TracktionEngine
Public Member Functions | List of all members
tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool Struct Referenceabstract

Base class for thread pools which can be customised to determine how cooperative threads should behave. More...

Public Member Functions

 ThreadPool (LockFreeMultiThreadedNodePlayer &p)
 Constructs a ThreadPool for a given LockFreeMultiThreadedNodePlayer. More...
 
virtual ~ThreadPool ()=default
 Destructor. More...
 
virtual void createThreads (size_t numThreads)=0
 Subclasses should implement this to create the given number of threads. More...
 
virtual void clearThreads ()=0
 Subclasses should implement this to clear all the threads. More...
 
virtual void signalOne ()=0
 Called by the player when a Node becomes available to process. More...
 
virtual void signal (int numToSignal)=0
 Called by the player when more than one Node becomes available to process. More...
 
virtual void signalAll ()=0
 Called by the player when more than one Node becomes available to process. More...
 
virtual void waitForFinalNode ()=0
 Called by the player when the audio thread has no free Nodes to process. More...
 
void signalShouldExit ()
 Signals the pool that all the threads should exit. More...
 
void resetExitSignal ()
 Signals the pool that all the threads should continue to run and not exit. More...
 
bool shouldExit () const
 Returns true if all the threads should exit. More...
 
bool shouldWait ()
 Returns true if there are no free Nodes to be processed and the calling thread should wait until there are Nodes ready. More...
 
bool isFinalNodeReady ()
 Returns true if all the Nodes have been processed. More...
 
bool process ()
 Process the next chain of Nodes. More...
 
void setCurrentNode (LockFreeMultiThreadedNodePlayer::PreparedNode *nodeInUse)
 Sets the current PreparedNode in use. More...
 

Detailed Description

Base class for thread pools which can be customised to determine how cooperative threads should behave.

Constructor & Destructor Documentation

◆ ThreadPool()

tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::ThreadPool ( LockFreeMultiThreadedNodePlayer p)

Constructs a ThreadPool for a given LockFreeMultiThreadedNodePlayer.

◆ ~ThreadPool()

virtual tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::~ThreadPool ( )
virtualdefault

Destructor.

Member Function Documentation

◆ createThreads()

virtual void tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::createThreads ( size_t  numThreads)
pure virtual

Subclasses should implement this to create the given number of threads.

◆ clearThreads()

virtual void tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::clearThreads ( )
pure virtual

Subclasses should implement this to clear all the threads.

◆ signalOne()

virtual void tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::signalOne ( )
pure virtual

Called by the player when a Node becomes available to process.

Subclasses should use this to try and get a thread to call process as soon as possible.

◆ signal()

virtual void tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::signal ( int  numToSignal)
pure virtual

Called by the player when more than one Node becomes available to process.

Subclasses should use this to try and get a thread to call process as soon as possible.

◆ signalAll()

virtual void tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::signalAll ( )
pure virtual

Called by the player when more than one Node becomes available to process.

Subclasses should use this to try and get a thread to call process as soon as possible.

Referenced by signalShouldExit().

◆ waitForFinalNode()

virtual void tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::waitForFinalNode ( )
pure virtual

Called by the player when the audio thread has no free Nodes to process.

Subclasses should can use this to either spin, pause or wait until a Node does become free or isFinalNodeReady returns true.

◆ signalShouldExit()

void tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::signalShouldExit ( )

Signals the pool that all the threads should exit.

References signalAll().

◆ resetExitSignal()

void tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::resetExitSignal ( )

Signals the pool that all the threads should continue to run and not exit.

◆ shouldExit()

bool tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::shouldExit ( ) const

Returns true if all the threads should exit.

Referenced by setCurrentNode(), and shouldWait().

◆ shouldWait()

bool tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::shouldWait ( )

Returns true if there are no free Nodes to be processed and the calling thread should wait until there are Nodes ready.

References shouldExit().

◆ isFinalNodeReady()

bool tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::isFinalNodeReady ( )

Returns true if all the Nodes have been processed.

◆ process()

bool tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::process ( )

Process the next chain of Nodes.

Returns true if at least one Node was processed, false if no Nodes were processed. You can use this to determine how long to pause/wait for before processing again.

◆ setCurrentNode()

void tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPool::setCurrentNode ( LockFreeMultiThreadedNodePlayer::PreparedNode *  nodeInUse)

Sets the current PreparedNode in use.

This should live as long as the threads are running once set.

References shouldExit().


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