libAlgAudio
v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
|
#include <LateReturn.hpp>
Public Member Functions | |
Sync (int count) | |
void | Trigger () const |
void | WhenAll (std::function< void()> func) const |
Sync is a helper class that makes it easy to wait for multiple LateReplies to arrive.
Sync maintains an internal counter that is initially set to some value. Each finished LateReturn decrements the counter, when it reaches zero the stored function (set by WhenAll) is called.
Example usage:
Sync instances are shared; when copy-assigning or copy-constructing a sync, it will use the same counter. Therefore, when using Sync in lambda functions, it is recommended to pass Sync instances by-value.
AlgAudio::Sync::Sync | ( | int | count | ) |
Constructs a new instance of a Sync.
count | The number of LateReplies to wait for. |
void AlgAudio::Sync::Trigger | ( | ) | const |
Decrements the internal counter, and, potentially, invokes the stored function.
void AlgAudio::Sync::WhenAll | ( | std::function< void()> | func | ) | const |
Sets the function that is supposed to happen when the counter gets down to zero.
func | The parram-less function to call. |