|
TracktionEngine
|
Base class for thread pools which can be customised to determine how cooperative threads should behave. More...
#include <tracktion_LockFreeMultiThreadedNodePlayer.h>
Public Member Functions | |
| ThreadPool (LockFreeMultiThreadedNodePlayer &p) | |
| Constructs a ThreadPool for a given LockFreeMultiThreadedNodePlayer. | |
| virtual | ~ThreadPool ()=default |
| Destructor. | |
| virtual void | createThreads (size_t numThreads, juce::AudioWorkgroup)=0 |
| Subclasses should implement this to create the given number of threads. | |
| virtual void | clearThreads ()=0 |
| Subclasses should implement this to clear all the threads. | |
| virtual void | signalOne ()=0 |
| Called by the player when a Node becomes available to process. | |
| virtual void | signal (int numToSignal)=0 |
| Called by the player when more than one Node becomes available to process. | |
| virtual void | signalAll ()=0 |
| Called by the player when more than one Node becomes available to process. | |
| virtual void | waitForFinalNode ()=0 |
| Called by the player when the audio thread has no free Nodes to process. | |
| void | signalShouldExit () |
| Signals the pool that all the threads should exit. | |
| void | resetExitSignal () |
| Signals the pool that all the threads should continue to run and not exit. | |
| bool | shouldExit () const |
| Returns true if all the threads should exit. | |
| bool | shouldWait () |
| Returns true if there are no free Nodes to be processed and the calling thread should wait until there are Nodes ready. | |
| bool | isFinalNodeReady () |
| Returns true if all the Nodes have been processed. | |
| bool | process () |
| Process the next chain of Nodes. | |
| void | waitForThreadsToQuiesce () |
| Waits until no pool threads are inside a process() call. | |
| void | setCurrentNode (LockFreeMultiThreadedNodePlayer::PreparedNode *nodeInUse) |
| Sets the current PreparedNode in use. | |
Public Attributes | |
| LockFreeMultiThreadedNodePlayer & | player |
Base class for thread pools which can be customised to determine how cooperative threads should behave.
| graph::LockFreeMultiThreadedNodePlayer::ThreadPool::ThreadPool | ( | LockFreeMultiThreadedNodePlayer & | p | ) |
Constructs a ThreadPool for a given LockFreeMultiThreadedNodePlayer.
|
virtualdefault |
Destructor.
|
pure virtual |
Subclasses should implement this to create the given number of threads.
|
pure virtual |
Subclasses should implement this to clear all the threads.
|
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.
|
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.
|
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.
|
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.
| void graph::LockFreeMultiThreadedNodePlayer::ThreadPool::signalShouldExit | ( | ) |
Signals the pool that all the threads should exit.
| void graph::LockFreeMultiThreadedNodePlayer::ThreadPool::resetExitSignal | ( | ) |
Signals the pool that all the threads should continue to run and not exit.
| bool graph::LockFreeMultiThreadedNodePlayer::ThreadPool::shouldExit | ( | ) | const |
Returns true if all the threads should exit.
| bool 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.
| bool graph::LockFreeMultiThreadedNodePlayer::ThreadPool::isFinalNodeReady | ( | ) |
Returns true if all the Nodes have been processed.
| bool 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.
| void graph::LockFreeMultiThreadedNodePlayer::ThreadPool::waitForThreadsToQuiesce | ( | ) |
Waits until no pool threads are inside a process() call.
Call this from a non-real-time thread, once a retired PreparedNode is no longer reachable via setCurrentNode, to ensure no pool threads can still be reading it before it is destroyed.
| void graph::LockFreeMultiThreadedNodePlayer::ThreadPool::setCurrentNode | ( | LockFreeMultiThreadedNodePlayer::PreparedNode * | nodeInUse | ) |
Sets the current PreparedNode in use.
Once set, this must stay alive until a newer PreparedNode has been set here and waitForThreadsToQuiesce has subsequently returned.
| LockFreeMultiThreadedNodePlayer& graph::LockFreeMultiThreadedNodePlayer::ThreadPool::player |