A wrapper around a task that is supposed to take a while and is not allowed to be executed simultaneously to the audio rendering. More...
Public Types | |
enum | ReturnType { ExecutedSynchronously, DeferredToThread } |
The call() method will return one of these to indicate what happened. More... | |
Static Public Member Functions | |
static ReturnType | call (MainController *mc, const ProcessorFunction &f, int TargetThread=IDs::Threads::Loading) |
Executes the function passed as lambda and returns the ReturnType depending on the execution state of the function. More... | |
static ReturnType | call (Processor *p, const ProcessorFunction &f, int TargetThread=IDs::Threads::Loading) |
Executes the function passed as lambda for the given processor and returns the ReturnType depending on the execution state of the function. More... | |
A wrapper around a task that is supposed to take a while and is not allowed to be executed simultaneously to the audio rendering.
Some tasks that interfere with the audio rendering (eg. adding / removing modules, swapping samples) have to make sure that the audio thread is not running in parallel. Therefore HISE has a "suspended task" system which kills all voices, waits until the voices have gracefully faded out (including FX tails for reverb effects), then suspends the audio rendering until the task has been completed on a background thread with a minimal amount of locking.
In HISE, this system is used for each one of these events:
You can see this system in action if you do one of these things in HISE while playing notes.
In order to use that system from your own C++ code, just create a lambda that follows the hise::SafeFunctionCall definition and pass it to the call() function:
This makes sure that the lambda will be executed on the given thread after all voices are killed. However this doesn't necessarily mean asynchronous execution: if you're calling this on the target thread and all voices are already killed, it will be executed synchronously. You can check this with the ReturnType enum passed back from the call() method. This reduces the debugging headaches of asynchronous callbacks wherever possible.
enum ReturnType |
The call() method will return one of these to indicate what happened.
|
inlinestatic |
Executes the function passed as lambda and returns the ReturnType depending on the execution state of the function.
If you want to specify the processor being used, use the other call() method.
|
inlinestatic |
Executes the function passed as lambda for the given processor and returns the ReturnType depending on the execution state of the function.