diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-08 21:45:03 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-08 21:45:03 +0000 |
commit | 331e2dc8eb69b093bf012d8dcd1ab652d67fc36b (patch) | |
tree | f48b803413351f38138f18f601da8cf5bab58060 /src/ports/SkThread_win.cpp | |
parent | f51018d8f954cc644cc875dc1faab386fd6e85e3 (diff) |
add flag/hint to PlatformGetSpecific. If true, then the caller requires that
the tls slot be allocated even if this is the first, to ensure that it can
later call PlatformSetSpecific. When this is false (which is most of the time)
the implementation may optimize by not even creating the slot, and just
returning null.
git-svn-id: http://skia.googlecode.com/svn/trunk@3871 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports/SkThread_win.cpp')
-rw-r--r-- | src/ports/SkThread_win.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ports/SkThread_win.cpp b/src/ports/SkThread_win.cpp index 0d9ecab4bd..6c960e25a9 100644 --- a/src/ports/SkThread_win.cpp +++ b/src/ports/SkThread_win.cpp @@ -51,11 +51,17 @@ static bool gOnce; static DWORD gTlsIndex; SK_DECLARE_STATIC_MUTEX(gMutex); -void* SkTLS::PlatformGetSpecific() { +void* SkTLS::PlatformGetSpecific(bool forceCreateTheSlot) { + if (!forceCreateTheSlot && !gOnce) { + return NULL; + } + if (!gOnce) { SkAutoMutexAcquire tmp(gMutex); - gTlsIndex = TlsAlloc(); - gOnce = true; + if (!gOnce) { + gTlsIndex = TlsAlloc(); + gOnce = true; + } } return TlsGetValue(gTlsIndex); } |