|
tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications
« « « Anklang Documentation |
Manages access to an object in a way that means it is lock-free to access from a real-time thread. More...
#include "tracktion_LockFreeObject.h"
Classes | |
| class | ScopedRealTimeAccess |
| Helper class to automatically retain/release real time access to an object. More... | |
Public Member Functions | |
| LockFreeObject () | |
| Constructs an initially empty object. | |
| void | clear () |
| Clears the object and any pending object by assigining them defaultly constructed objects. | |
| void | pushNonRealTime (ObjectType &&newObj) |
| Pushes a new object to be picked up on the real time thread. | |
| ObjectType * | retainRealTime () |
| Retains the object for use in a real time thread. | |
| void | releaseRealTime () |
| Releases the use of the object from a previous call to retainRealTime. | |
| ScopedRealTimeAccess | getScopedAccess () |
| Creates a ScopedRealTimeAccess for this LockFreeObject. | |
Manages access to an object in a way that means it is lock-free to access from a real-time thread.
This initially starts empty so call pushNonRealTime to queue an object. You can then get at this object using retainRealTime. It's thread safe to call pushNonRealTime as many times as you like, retainRealTime will just return the old object whilst those calls are in progress. Calls to pushNonRealTime may have to wait for the real time access to complete, signified by a call to releaseRealTime.
Additionally, you may want to clear the objects e.g. releasing some resource they have stored. This can be done with the clear call. Whilst this is happening, retainRealTime will still be lock-free but will return nullptr signifying no object can be used.
Definition at line 37 of file tracktion_LockFreeObject.h.
| tracktion::graph::LockFreeObject< ObjectType >::LockFreeObject | ( | ) |
Constructs an initially empty object.
Use the pushNonRealTime function to queue one for real-time access.
Definition at line 43 of file tracktion_LockFreeObject.h.
| void tracktion::graph::LockFreeObject< ObjectType >::clear | ( | ) |
Clears the object and any pending object by assigining them defaultly constructed objects.
Definition at line 50 of file tracktion_LockFreeObject.h.
| ScopedRealTimeAccess tracktion::graph::LockFreeObject< ObjectType >::getScopedAccess | ( | ) |
Creates a ScopedRealTimeAccess for this LockFreeObject.
Definition at line 149 of file tracktion_LockFreeObject.h.
| void tracktion::graph::LockFreeObject< ObjectType >::pushNonRealTime | ( | ObjectType && | newObj | ) |
Pushes a new object to be picked up on the real time thread.
Definition at line 63 of file tracktion_LockFreeObject.h.
| void tracktion::graph::LockFreeObject< ObjectType >::releaseRealTime | ( | ) |
Releases the use of the object from a previous call to retainRealTime.
Definition at line 110 of file tracktion_LockFreeObject.h.
| ObjectType * tracktion::graph::LockFreeObject< ObjectType >::retainRealTime | ( | ) |
Retains the object for use in a real time thread.
If a previous push call has finished, this will update and use the newly pushed object. If a clear call is in progress this will return nullptr.
This must be matched with a corresponding call to releaseRealTime(). To Ensure this, use the ScopedRealTimeAccess helper class.
Definition at line 79 of file tracktion_LockFreeObject.h.