1 --- a/engine/Thread.cpp
2 +++ b/engine/Thread.cpp
3 @@ -106,21 +106,18 @@ static DWORD getTls()
7 -static pthread_key_t current_key;
9 -class ThreadPrivateKeyAlloc
10 +static pthread_key_t& current_key()
13 - ThreadPrivateKeyAlloc()
15 - if (::pthread_key_create(¤t_key,ThreadPrivate::destroyFunc)) {
16 + static pthread_key_t* current_key = NULL;
18 + current_key = new pthread_key_t;
19 + if (::pthread_key_create(current_key, ThreadPrivate::destroyFunc)) {
21 Debug(DebugFail,"Failed to create current thread key!");
26 -static ThreadPrivateKeyAlloc keyAllocator;
27 + return *current_key;
31 static TokenDict s_prio[] = {
32 @@ -309,7 +306,7 @@ void ThreadPrivate::run()
34 ::TlsSetValue(getTls(),this);
36 - ::pthread_setspecific(current_key,this);
37 + ::pthread_setspecific(current_key(),this);
38 pthread_cleanup_push(cleanupFunc,this);
39 #ifdef PTHREAD_CANCEL_ASYNCHRONOUS
40 ::pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,0);
41 @@ -421,7 +418,7 @@ ThreadPrivate* ThreadPrivate::current()
43 return reinterpret_cast<ThreadPrivate *>(::TlsGetValue(getTls()));
45 - return reinterpret_cast<ThreadPrivate *>(::pthread_getspecific(current_key));
46 + return reinterpret_cast<ThreadPrivate *>(::pthread_getspecific(current_key()));