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 30 of file id_tracker.cpp.hpp.

30 {
31 if (!ptr || !outId) {
32 return false;
33 }
34
35 // Lock for thread safety
36 mMutex.lock();
37
38 auto it = mPointerToId.find(ptr);
39 bool found = (it != mPointerToId.end());
40 if (found) {
41 *outId = it->second;
42 }
43
44 mMutex.unlock();
45 return found;
46}
fl::flat_map< void *, int > mPointerToId
Definition id_tracker.h:91
fl::mutex mMutex
Definition id_tracker.h:88

References FL_NOEXCEPT, mMutex, and mPointerToId.

Referenced by IdTracker().

+ Here is the caller graph for this function: