46template <
typename Type>
58 for (
auto* o = first.
get(); o !=
nullptr;)
78 operator Type*()
const noexcept {
return &
get(); }
95 Type&
get() const noexcept
98 ObjectHolder* o =
nullptr;
100 for (o = first.
get(); o !=
nullptr; o = o->next)
101 if (o->threadId.get() == threadId)
104 for (o = first.
get(); o !=
nullptr; o = o->next)
105 if (o->threadId.compareAndSetBool (threadId,
nullptr))
111 for (o =
new ObjectHolder (threadId, first.
get());
113 o->next = first.
get());
125 for (
auto* o = first.
get(); o !=
nullptr; o = o->next)
126 if (o->threadId.compareAndSetBool (
nullptr, threadId))
134 ObjectHolder (
Thread::ThreadID idToUse, ObjectHolder* n) : threadId (idToUse), next (n), object() {}
136 Atomic<Thread::ThreadID> threadId;
140 JUCE_DECLARE_NON_COPYABLE (ObjectHolder)
143 mutable Atomic<ObjectHolder*> first;
145 JUCE_DECLARE_NON_COPYABLE (ThreadLocalValue)
Type & operator*() const noexcept
Type * operator->() const noexcept
void releaseCurrentThreadStorage()
Type & get() const noexcept
ThreadLocalValue & operator=(const Type &newValue)
static ThreadID JUCE_CALLTYPE getCurrentThreadId()
Type get() const noexcept
bool compareAndSetBool(Type newValue, Type valueToCompare) noexcept