Vuo  1.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Member Functions | List of all members
VuoThreadManager Class Reference

Description

Manages the number of threads used by a composition to avoid hitting the Dispatch Thread Soft Limit.

When a composition needs to schedule a block of code that may need to wait on stuff, it requests a thread from the thread manager. The thread manager, which manages several thread pools, schedules the block of code when a thread becomes available. When the block of code completes, the composition informs the thread manager, and the thread manager returns the threads to their thread pool.

Public Member Functions

 VuoThreadManager (void)
 Constructor.
 
 ~VuoThreadManager (void)
 Destructor.
 
void enableSchedulingWorkers (void)
 Starts dequeuing workers as they are scheduled.
 
void disableSchedulingWorkers (void)
 Finishes dequeuing workers that have been scheduled.
 
void scheduleTriggerWorker (dispatch_queue_t queue, void *context, void(*function)(void *), int minThreadsNeeded, int maxThreadsNeeded, unsigned long eventId, const char *compositionIdentifier, int chainCount)
 Schedules a trigger worker function to be called when enough threads are available from the thread pool.
 
void scheduleChainWorker (dispatch_queue_t queue, void *context, void(*function)(void *), int minThreadsNeeded, int maxThreadsNeeded, unsigned long eventId, const char *compositionIdentifier, unsigned long chainIndex, unsigned long *upstreamChainIndices, int upstreamChainIndicesCount)
 Schedules a chain worker function to be called when enough threads are available from the thread pool.
 
void grantThreadsToChain (int minThreadsNeeded, int maxThreadsNeeded, unsigned long eventId, const char *compositionIdentifier, unsigned long chainIndex)
 Allocates threads for use by a chain executed synchronously by the caller instead of scheduled with vuoScheduleChainWorker().
 
void grantThreadsToSubcomposition (unsigned long eventId, const char *compositionIdentifier, unsigned long chainIndex, const char *subcompositionIdentifier)
 Allows the published input trigger of a subcomposition node to use the threads allocated for the chain containing the node.
 
void returnThreadsForTriggerWorker (unsigned long eventId)
 Returns the threads allocated for the trigger worker to the thread pool.
 
void returnThreadsForChainWorker (unsigned long eventId, const char *compositionIdentifier, unsigned long chainIndex)
 Returns the threads allocated for the chain worker to the thread pool.
 

Constructor & Destructor Documentation

VuoThreadManager::VuoThreadManager ( void  )

Constructor.

VuoThreadManager::~VuoThreadManager ( void  )

Destructor.

Member Function Documentation

void VuoThreadManager::disableSchedulingWorkers ( void  )

Finishes dequeuing workers that have been scheduled.

void VuoThreadManager::enableSchedulingWorkers ( void  )

Starts dequeuing workers as they are scheduled.

void VuoThreadManager::grantThreadsToChain ( int  minThreadsNeeded,
int  maxThreadsNeeded,
unsigned long  eventId,
const char *  compositionIdentifier,
unsigned long  chainIndex 
)

Allocates threads for use by a chain executed synchronously by the caller instead of scheduled with vuoScheduleChainWorker().

After this function is called, vuoReturnThreadsForChainWorker() should be called to return the threads to the thread pool.

void VuoThreadManager::grantThreadsToSubcomposition ( unsigned long  eventId,
const char *  compositionIdentifier,
unsigned long  chainIndex,
const char *  subcompositionIdentifier 
)

Allows the published input trigger of a subcomposition node to use the threads allocated for the chain containing the node.

This function should be called before vuoScheduleTriggerWorker() is called for the published input trigger.

void VuoThreadManager::returnThreadsForChainWorker ( unsigned long  eventId,
const char *  compositionIdentifier,
unsigned long  chainIndex 
)

Returns the threads allocated for the chain worker to the thread pool.

void VuoThreadManager::returnThreadsForTriggerWorker ( unsigned long  eventId)

Returns the threads allocated for the trigger worker to the thread pool.

void VuoThreadManager::scheduleChainWorker ( dispatch_queue_t  queue,
void *  context,
void(*)(void *)  function,
int  minThreadsNeeded,
int  maxThreadsNeeded,
unsigned long  eventId,
const char *  compositionIdentifier,
unsigned long  chainIndex,
unsigned long *  upstreamChainIndices,
int  upstreamChainIndicesCount 
)

Schedules a chain worker function to be called when enough threads are available from the thread pool.

After this function is called, vuoReturnThreadsForChainWorker() should be called to return the threads to the thread pool.

void VuoThreadManager::scheduleTriggerWorker ( dispatch_queue_t  queue,
void *  context,
void(*)(void *)  function,
int  minThreadsNeeded,
int  maxThreadsNeeded,
unsigned long  eventId,
const char *  compositionIdentifier,
int  chainCount 
)

Schedules a trigger worker function to be called when enough threads are available from the thread pool.

For the published input trigger of a subcomposition node, pass -1 for minThreadsNeeded and maxThreadsNeeded.

After this function is called, either vuoReturnThreadsForTriggerWorker() should be called for the trigger or vuoReturnThreadsForChainWorker() should be called for each chain downstream of the trigger.


The documentation for this class was generated from the following files: