44 Dispatcher(std::shared_ptr<Tracer> tracer = {}, AudioObjectID hintMaximumID = 1000);
53 std::shared_ptr<Object>
FindObject(AudioObjectID objectID)
const;
61 AudioObjectID objectID = kAudioObjectUnknown);
73 explicit Registration(
Object* obj)
78 std::atomic<Object*> object;
79 std::shared_mutex mutex;
82 AudioObjectID AllocateID();
83 void FreeID(AudioObjectID objectID);
85 AudioObjectID FindFreeID(AudioObjectID startID)
const;
86 bool IsFree(AudioObjectID objectID)
const;
87 void SetFree(AudioObjectID objectID,
bool free);
89 using BitChunk = UInt64;
90 static constexpr size_t BitsPerChunk =
sizeof(BitChunk) * 8;
93 const std::shared_ptr<Tracer> tracer_;
96 const std::unordered_set<AudioObjectID> reservedIDs_ = {
98 kAudioObjectPlugInObject,
106 DoubleBuffer<std::unordered_map<AudioObjectID, std::shared_ptr<Registration>>>
110 std::mutex registrationMutex_;
113 std::vector<BitChunk> allocatedBits_;
115 size_t numAllocatedIDs_ = 0;
116 AudioObjectID lastAllocatedID_ = 0;
123 AudioObjectID desiredMaximumID_;
AudioObjectID RegisterObject(Object &object, AudioObjectID objectID=kAudioObjectUnknown)
Register new object. If objectID is kAudioObjectUnknown (zero), a new ID is allocated....
Dispatcher(std::shared_ptr< Tracer > tracer={}, AudioObjectID hintMaximumID=1000)
Construct dispatcher. Use tracer if you want to debug dispatcher itself, it is quite verbose.