|
JPL Spatial
Sound spatialization and propagation library
|
#include <JPLSpatial/Utilities/RealtimeObject.h>
Classes | |
| class | ScopedAccess |
Public Types | |
| using | allocator_type = std::pmr::polymorphic_allocator<> |
| using | RealtimeAcquireReturnType = std::conditional_t< Options==RealtimeObjectOptions::nonRealtimeMutatable, const T, T > |
| using | NonRealtimeAcquireReturnType = std::conditional_t< Options==RealtimeObjectOptions::realtimeMutatable, const T, T > |
Public Member Functions | |
| RealtimeObject ()=default | |
| RealtimeObject (const T &obj, const allocator_type &allocator={}) | |
| RealtimeObject (T &&obj, const allocator_type &allocator={}) | |
| ~RealtimeObject ()=default | |
| RealtimeAcquireReturnType & | realtimeAcquire () noexcept |
| void | realtimeRelease () noexcept |
| template<typename... Args> requires (Options == RealtimeObjectOptions::realtimeMutatable) | |
| void | realtimeReplace (Args &&... args) noexcept |
| NonRealtimeAcquireReturnType & | nonRealtimeAcquire () |
| void | nonRealtimeRelease () |
| template<typename... Args> requires (Options == RealtimeObjectOptions::nonRealtimeMutatable) | |
| void | nonRealtimeReplace (Args &&... args) |
Useful class to synchronise access to an object from multiple threads with the additional feature that one designated thread will never wait to get access to the object.
Essentially Faiban Renn's RealtimeObject (https://github.com/hogliux/farbot), with some modifications:
| using JPL::RealtimeObject< T, Options >::allocator_type = std::pmr::polymorphic_allocator<> |
| using JPL::RealtimeObject< T, Options >::NonRealtimeAcquireReturnType = std::conditional_t<Options == RealtimeObjectOptions::realtimeMutatable, const T, T> |
| using JPL::RealtimeObject< T, Options >::RealtimeAcquireReturnType = std::conditional_t<Options == RealtimeObjectOptions::nonRealtimeMutatable, const T, T> |
|
default |
Creates a default constructed T
|
inlineexplicit |
Creates a copy of T
|
inlineexplicit |
Moves T into this realtime wrapper
|
default |
|
inline |
Returns a reference to T. Use this method on the non real-time thread. It must be matched by nonRealtimeRelease when you are finished using the object. Alternatively, use the ScopedAccess helper class below.
Multiple non-realtime threads can acquire an object at the same time.
This method uses a lock should not be used on a realtime thread.
|
inline |
Releases the lock on T previously acquired by nonRealtimeAcquire.
This method uses both a lock and a spin loop and should not be used on a realtime thread.
|
inline |
Replace the underlying value with a new instance of T by forwarding the method's arguments to T's constructor
|
inlinenoexcept |
Returns a reference to T. Use this method on the real-time thread. It must be matched by realtimeRelease when you are finished using the object. Alternatively, use the ScopedAccess helper class below.
Only a single real-time thread can acquire this object at once!
This method is wait- and lock-free.
|
inlinenoexcept |
Releases the lock on T previously acquired by realtimeAcquire.
This method is wait- and lock-free.
|
inlinenoexcept |
Replace the underlying value with a new instance of T by forwarding the method's arguments to T's constructor