FastLED 3.9.15
Loading...
Searching...
No Matches

◆ getId()

bool fl::IdTracker::getId ( void * ptr,
int * outId )

Get existing ID for pointer without creating a new one.

Thread-safe.

Parameters
ptrPointer to look up
outIdPointer to store the ID if found
Returns
true if ID was found, false if pointer not tracked

Definition at line 29 of file id_tracker.cpp.

29 {
30 if (!ptr || !outId) {
31 return false;
32 }
33
34 // Lock for thread safety
35 mMutex.lock();
36
37 const int* existingId = mPointerToId.find_value(ptr);
38 bool found = (existingId != nullptr);
39 if (found) {
40 *outId = *existingId;
41 }
42
43 mMutex.unlock();
44 return found;
45}
fl::hash_map< void *, int > mPointerToId
Definition id_tracker.h:92
fl::mutex mMutex
Definition id_tracker.h:89

References mMutex, and mPointerToId.