libASPL
Loading...
Searching...
No Matches
aspl::Dispatcher Class Reference

Object dispatcher. More...

#include <aspl/Dispatcher.hpp>

Public Member Functions

 Dispatcher (std::shared_ptr< Tracer > tracer={}, AudioObjectID hintMaximumID=1000)
 Construct dispatcher. Use tracer if you want to debug dispatcher itself, it is quite verbose.
 
 Dispatcher (const Dispatcher &)=delete
 
Dispatcheroperator= (const Dispatcher &)=delete
 
std::shared_ptr< ObjectFindObject (AudioObjectID objectID) const
 Find registered object by ID. Returns null if there is no such object.
 
AudioObjectID RegisterObject (Object &object, AudioObjectID objectID=kAudioObjectUnknown)
 Register new object. If objectID is kAudioObjectUnknown (zero), a new ID is allocated. Otherwise, given ID is used.
 
void UnregisterObject (AudioObjectID objectID)
 Unregister previously registered object. It's guaranteed that after this method returns, the registered object is not accessed by dispatcher anymore and can be destroyed.
 

Detailed Description

Object dispatcher.

Every object registers itself here in its constructor, and unregisters in destructor.

Dispatcher allocates object identifiers and maps identifiers to objects. Freed identifiers are reused.

The allocation algorithm tries to delay identifier reuse for a while, to give you a chance to catch bugs with looking up recently freed objects.

Dispatcher stores weak references to objects and thus does not affect their reference counter.

Definition at line 39 of file Dispatcher.hpp.

Constructor & Destructor Documentation

◆ Dispatcher()

aspl::Dispatcher::Dispatcher ( std::shared_ptr< Tracer > tracer = {},
AudioObjectID hintMaximumID = 1000 )

Construct dispatcher. Use tracer if you want to debug dispatcher itself, it is quite verbose.

Member Function Documentation

◆ FindObject()

std::shared_ptr< Object > aspl::Dispatcher::FindObject ( AudioObjectID objectID) const

Find registered object by ID. Returns null if there is no such object.

Note
This method can be called from realtime threads.

◆ RegisterObject()

AudioObjectID aspl::Dispatcher::RegisterObject ( Object & object,
AudioObjectID objectID = kAudioObjectUnknown )

Register new object. If objectID is kAudioObjectUnknown (zero), a new ID is allocated. Otherwise, given ID is used.

Note
This method should not be called from realtime threads.

◆ UnregisterObject()

void aspl::Dispatcher::UnregisterObject ( AudioObjectID objectID)

Unregister previously registered object. It's guaranteed that after this method returns, the registered object is not accessed by dispatcher anymore and can be destroyed.

Note
This method should not be called from realtime threads.

The documentation for this class was generated from the following file: