TuttleOFX  1
OfxMultiThreadSuiteV1 Struct Reference

OFX suite that provides simple SMP style multi-processing. More...

#include <ofxMultiThread.h>

Data Fields

OfxStatus(* multiThread )(OfxThreadFunctionV1 func, const unsigned int nThreads, void *customArg)
 Function to spawn SMP threads.
OfxStatus(* multiThreadNumCPUs )(unsigned int *const nCPUs)
 Function which indicates the number of CPUs available for SMP processing.
OfxStatus(* multiThreadIndex )(unsigned int *const threadIndex)
 Function which indicates the index of the current thread.
int(* multiThreadIsSpawnedThread )(void)
 Function to enquire if the calling thread was spawned by multiThread.
OfxStatus(* mutexCreate )(OfxMutexHandle *mutex, const int lockCount)
 Create a mutex.
OfxStatus(* mutexDestroy )(OfxMutexHandle mutex)
 Destroy a mutex.
OfxStatus(* mutexLock )(OfxMutexHandle mutex)
 Blocking lock on the mutex.
OfxStatus(* mutexUnLock )(OfxMutexHandle mutex)
 Unlock the mutex.
OfxStatus(* mutexTryLock )(OfxMutexHandle mutex)
 Non blocking attempt to lock the mutex.

Detailed Description

OFX suite that provides simple SMP style multi-processing.

Definition at line 65 of file ofxMultiThread.h.


Field Documentation

OfxStatus( * OfxMultiThreadSuiteV1::multiThread)(OfxThreadFunctionV1 func, const unsigned int nThreads, void *customArg)

Function to spawn SMP threads.

  • func The function to call in each thread.
  • nThreads The number of threads to launch
  • customArg The paramter to pass to customArg of func in each thread.

This function will spawn nThreads separate threads of computation (typically one per CPU) to allow something to perform symmetric multi processing. Each thread will call 'func' passing in the index of the thread and the number of threads actually launched.

multiThread will not return until all the spawned threads have returned. It is up to the host how it waits for all the threads to return (busy wait, blocking, whatever).

nThreads can be more than the value returned by multiThreadNumCPUs, however the threads will be limitted to the number of CPUs returned by multiThreadNumCPUs.

This function cannot be called recursively.

Returns:

Definition at line 91 of file ofxMultiThread.h.

Referenced by OFX::MultiThread::Processor::multiThread().

OfxStatus( * OfxMultiThreadSuiteV1::multiThreadIndex)(unsigned int *const threadIndex)

Function which indicates the index of the current thread.

  • threadIndex pointer to an integer where the result is returned

This function returns the thread index, which is the same as the threadIndex argument passed to the OfxThreadFunctionV1.

If there are no threads currently spawned, then this function will set threadIndex to 0

Returns:
  • kOfxStatOK, all was OK and the maximum number of threads is in nThreads.
  • kOfxStatFailed, the function failed to return an index

Definition at line 119 of file ofxMultiThread.h.

Referenced by OFX::MultiThread::getThreadIndex().

Function to enquire if the calling thread was spawned by multiThread.

Returns:
  • 0 if the thread is not one spawned by multiThread
  • 1 if the thread was spawned by multiThread

Definition at line 127 of file ofxMultiThread.h.

Referenced by OFX::MultiThread::isSpawnedThread().

OfxStatus( * OfxMultiThreadSuiteV1::multiThreadNumCPUs)(unsigned int *const nCPUs)

Function which indicates the number of CPUs available for SMP processing.

  • nCPUs pointer to an integer where the result is returned

This value may be less than the actual number of CPUs on a machine, as the host may reserve other CPUs for itself.

Returns:
  • kOfxStatOK, all was OK and the maximum number of threads is in nThreads.
  • kOfxStatFailed, the function failed to get the number of CPUs

Definition at line 105 of file ofxMultiThread.h.

Referenced by OFX::MultiThread::getNumCPUs().

Create a mutex.

  • mutex - where the new handle is returned
  • count - initial lock count on the mutex. This can be negative.

Creates a new mutex with lockCount locks on the mutex intially set.

Returns:
  • kOfxStatOK - mutex is now valid and ready to go

Definition at line 139 of file ofxMultiThread.h.

Referenced by OFX::MultiThread::Mutex::Mutex().

Destroy a mutex.

Todo:
; ofxtuttle fix: no const on mutex

Destroys a mutex intially created by mutexCreate.

Returns:
  • kOfxStatOK - if it destroyed the mutex
  • kOfxStatErrBadHandle - if the handle was bad

Definition at line 149 of file ofxMultiThread.h.

Referenced by OFX::MultiThread::Mutex::~Mutex().

Blocking lock on the mutex.

Todo:
; ofxtuttle fix: no const on mutex

This trys to lock a mutex and blocks the thread it is in until the lock suceeds.

A sucessful lock causes the mutex's lock count to be increased by one and to block any other calls to lock the mutex until it is unlocked.

Returns:
  • kOfxStatOK - if it got the lock
  • kOfxStatErrBadHandle - if the handle was bad

Definition at line 161 of file ofxMultiThread.h.

Referenced by OFX::MultiThread::Mutex::lock().

Non blocking attempt to lock the mutex.

Todo:
; ofxtuttle fix: no const on mutex

This attempts to lock a mutex, if it cannot, it returns and says so, rather than blocking.

A sucessful lock causes the mutex's lock count to be increased by one, if the lock did not suceed, the call returns immediately and the lock count remains unchanged.

Returns:
  • kOfxStatOK - if it got the lock
  • kOfxStatFailed - if it did not get the lock
  • kOfxStatErrBadHandle - if the handle was bad

Definition at line 184 of file ofxMultiThread.h.

Referenced by OFX::MultiThread::Mutex::tryLock().

Unlock the mutex.

Todo:
; ofxtuttle fix: no const on mutex

This unlocks a mutex. Unlocking a mutex decreases its lock count by one.

Returns:
  • kOfxStatOK if it released the lock
  • kOfxStatErrBadHandle if the handle was bad

Definition at line 171 of file ofxMultiThread.h.

Referenced by OFX::MultiThread::Mutex::unlock().


The documentation for this struct was generated from the following file: