Vuo  2.0.0
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.

Definition at line 29 of file VuoThreadManager.hh.

Public Member Functions

 VuoThreadManager (void)
 Constructor. More...
 
 ~VuoThreadManager (void)
 Destructor. More...
 
void enableSchedulingWorkers (void)
 Starts dequeuing workers as they are scheduled. More...
 
void disableSchedulingWorkers (void)
 Finishes dequeuing workers that have been scheduled. More...
 
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. More...
 
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. More...
 
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(). More...
 
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. More...
 
void returnThreadsForTriggerWorker (unsigned long eventId)
 Returns the threads allocated for the trigger worker to the thread pool. More...
 
void returnThreadsForChainWorker (unsigned long eventId, const char *compositionIdentifier, unsigned long chainIndex)
 Returns the threads allocated for the chain worker to the thread pool. More...
 

Constructor & Destructor Documentation

◆ VuoThreadManager()

VuoThreadManager::VuoThreadManager ( void  )

Constructor.

Definition at line 228 of file VuoThreadManager.cc.

◆ ~VuoThreadManager()

VuoThreadManager::~VuoThreadManager ( void  )

Destructor.

Definition at line 240 of file VuoThreadManager.cc.

Member Function Documentation

◆ disableSchedulingWorkers()

void VuoThreadManager::disableSchedulingWorkers ( void  )

Finishes dequeuing workers that have been scheduled.

Definition at line 276 of file VuoThreadManager.cc.

◆ enableSchedulingWorkers()

void VuoThreadManager::enableSchedulingWorkers ( void  )

Starts dequeuing workers as they are scheduled.

Definition at line 250 of file VuoThreadManager.cc.

◆ grantThreadsToChain()

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.

Definition at line 466 of file VuoThreadManager.cc.

◆ grantThreadsToSubcomposition()

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.

Definition at line 488 of file VuoThreadManager.cc.

◆ returnThreadsForChainWorker()

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

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

Definition at line 517 of file VuoThreadManager.cc.

◆ returnThreadsForTriggerWorker()

void VuoThreadManager::returnThreadsForTriggerWorker ( unsigned long  eventId)

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

Definition at line 504 of file VuoThreadManager.cc.

◆ scheduleChainWorker()

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.

Definition at line 447 of file VuoThreadManager.cc.

◆ scheduleTriggerWorker()

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.

Definition at line 421 of file VuoThreadManager.cc.


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