50 template <
typename Type>
62 for (
auto* o = first.
get(); o !=
nullptr;)
82 operator Type*()
const noexcept {
return &
get(); }
99 Type&
get()
const noexcept
102 ObjectHolder* o =
nullptr;
104 for (o = first.
get(); o !=
nullptr; o = o->next)
105 if (o->threadId.get() == threadId)
108 for (o = first.
get(); o !=
nullptr; o = o->next)
109 if (o->threadId.compareAndSetBool (threadId,
nullptr))
115 for (o =
new ObjectHolder (threadId, first.
get());
117 o->next = first.
get());
129 for (
auto* o = first.
get(); o !=
nullptr; o = o->next)
130 if (o->threadId.compareAndSetBool (
nullptr, threadId))
138 ObjectHolder (
Thread::ThreadID idToUse, ObjectHolder* n) : threadId (idToUse), next (n), object() {}
144 JUCE_DECLARE_NON_COPYABLE (ObjectHolder)
void * ThreadID
A value type used for thread IDs.
void releaseCurrentThreadStorage()
Called by a thread before it terminates, to allow this class to release any storage associated with t...
static ThreadID JUCE_CALLTYPE getCurrentThreadId()
Returns an id that identifies the caller thread.
ThreadLocalValue & operator=(const Type &newValue)
Assigns a new value to the thread-local object.
Provides cross-platform support for thread-local objects.
Type get() const noexcept
Atomically reads and returns the current value.
Type * operator->() const noexcept
Accesses a method or field of the value object.
bool compareAndSetBool(Type newValue, Type valueToCompare) noexcept
Atomically compares this value with a target value, and if it is equal, sets this to be equal to a ne...
Type & operator*() const noexcept
Returns a reference to this thread's instance of the value.
~ThreadLocalValue()
Destructor.