diff options
Diffstat (limited to 'src/ports/SkThread_win.cpp')
-rw-r--r-- | src/ports/SkThread_win.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ports/SkThread_win.cpp b/src/ports/SkThread_win.cpp index 70b8e11122..0d9ecab4bd 100644 --- a/src/ports/SkThread_win.cpp +++ b/src/ports/SkThread_win.cpp @@ -10,6 +10,7 @@ #include <windows.h> #include <intrin.h> #include "SkThread.h" +#include "SkTLS.h" //MSDN says in order to declare an interlocked function for use as an //intrinsic, include intrin.h and put the function in a #pragma intrinsic @@ -44,3 +45,23 @@ void SkMutex::release() { LeaveCriticalSection(reinterpret_cast<CRITICAL_SECTION*>(&fStorage)); } +/////////////////////////////////////////////////////////////////////////// + +static bool gOnce; +static DWORD gTlsIndex; +SK_DECLARE_STATIC_MUTEX(gMutex); + +void* SkTLS::PlatformGetSpecific() { + if (!gOnce) { + SkAutoMutexAcquire tmp(gMutex); + gTlsIndex = TlsAlloc(); + gOnce = true; + } + return TlsGetValue(gTlsIndex); +} + +void SkTLS::PlatformSetSpecific(void* ptr) { + SkASSERT(gOnce); + (void)TlsSetValue(gTlsIndex, ptr); +} + |