29 #ifndef JUCE_THREADLOCALVALUE_H_INCLUDED 30 #define JUCE_THREADLOCALVALUE_H_INCLUDED 33 #if ! ((JUCE_MSVC && (JUCE_64BIT || ! defined (JucePlugin_PluginCode))) \ 34 || (JUCE_MAC && JUCE_CLANG && defined (MAC_OS_X_VERSION_10_7) \ 35 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7)) 36 #define JUCE_NO_COMPILER_THREAD_LOCAL 1 57 template <
typename Type>
71 #if JUCE_NO_COMPILER_THREAD_LOCAL 72 for (ObjectHolder* o = first.
value; o !=
nullptr;)
74 ObjectHolder*
const next = o->next;
93 operator Type*()
const noexcept {
return &
get(); }
112 #if JUCE_NO_COMPILER_THREAD_LOCAL 115 for (ObjectHolder* o = first.
get(); o !=
nullptr; o = o->next)
116 if (o->threadId == threadId)
119 for (ObjectHolder* o = first.
get(); o !=
nullptr; o = o->next)
121 if (o->threadId ==
nullptr)
126 if (o->threadId !=
nullptr)
129 o->threadId = threadId;
137 ObjectHolder*
const newObject =
new ObjectHolder (threadId);
141 newObject->next = first.
get();
145 return newObject->object;
147 static __thread Type
object;
150 static __declspec(thread) Type
object;
160 #if JUCE_NO_COMPILER_THREAD_LOCAL 163 for (ObjectHolder* o = first.
get(); o !=
nullptr; o = o->next)
165 if (o->threadId == threadId)
168 o->threadId =
nullptr;
176 #if JUCE_NO_COMPILER_THREAD_LOCAL 180 : threadId (tid), next (
nullptr),
object()
198 #endif // JUCE_THREADLOCALVALUE_H_INCLUDED void * ThreadID
Definition: juce_Thread.h:224
Type get() const noexcept
Definition: juce_Atomic.h:269
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_Atomic.h:41
Definition: juce_ScopedLock.h:59
static ThreadID JUCE_CALLTYPE getCurrentThreadId()
Definition: juce_posix_SharedCode.h:935
Definition: juce_SpinLock.h:46
Type & operator*() const noexcept
Definition: juce_ThreadLocalValue.h:86
~ThreadLocalValue()
Definition: juce_ThreadLocalValue.h:69
Type * operator->() const noexcept
Definition: juce_ThreadLocalValue.h:100
void releaseCurrentThreadStorage()
Definition: juce_ThreadLocalValue.h:158
volatile Type value
Definition: juce_Atomic.h:153
bool compareAndSetBool(Type newValue, Type valueToCompare) noexcept
Definition: juce_Atomic.h:347
Definition: juce_ThreadLocalValue.h:58
ThreadLocalValue() noexcept
Definition: juce_ThreadLocalValue.h:62
void * object
Definition: jmemsys.h:50
ThreadLocalValue & operator=(const Type &newValue)
Definition: juce_ThreadLocalValue.h:103