Fixed TLS.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Tue, 1 Jul 2003 19:41:22 +0000 (19:41 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Tue, 1 Jul 2003 19:41:22 +0000 (19:41 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@614 cb58f699-b61c-0410-a6fe-9272a202ed29

shib/shib-threads-win32.cpp

index 67aad16..3a36209 100644 (file)
@@ -329,19 +329,19 @@ public:
   }
 };
 
-static __declspec( thread ) void *thread_data;
 typedef void (*destroy_hook_type)(void*);
 
 class ThreadKeyImpl : public ThreadKey {
 private:
   destroy_hook_type destroy_hook;
+  DWORD key;
 
 public:
-  ThreadKeyImpl(void (*destroy_fcn)(void*)):destroy_hook(destroy_fcn){};
-  virtual ~ThreadKeyImpl() { destroy_hook(thread_data); }
+  ThreadKeyImpl(void (*destroy_fcn)(void*)) : destroy_hook(destroy_fcn) { key=TlsAlloc(); };
+  virtual ~ThreadKeyImpl() { destroy_hook(TlsGetValue(key)); TlsFree(key); }
 
-  int setData(void* data) { thread_data=data; return 0;}
-  void* getData() { return thread_data; }
+  int setData(void* data) { TlsSetValue(key,data); return 0;}
+  void* getData() { return TlsGetValue(key); }
   };
 
 //