Ignore:
Timestamp:
Mar 11, 2009, 1:39:21 PM (16 years ago)
Author:
Adam Roben
Message:

Change the Windows implementation of ThreadSpecific to use functions instead of extern globals

This will make it easier to export ThreadSpecific from WebKit.

Reviewed by John Sullivan.

  • API/JSBase.cpp: (JSEvaluateScript): Touched this file to force ThreadSpecific.h to be copied into $WebKitOutputDir.
  • wtf/ThreadSpecific.h: Replaced g_tls_key_count with tlsKeyCount() and g_tls_keys with tlsKeys().

(WTF::::ThreadSpecific):
(WTF::::~ThreadSpecific):
(WTF::::get):
(WTF::::set):
(WTF::::destroy):
Updated to use the new functions.

  • wtf/ThreadSpecificWin.cpp: (WTF::tlsKeyCount): (WTF::tlsKeys): Added.

(WTF::ThreadSpecificThreadExit): Changed to use the new functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/ThreadSpecificWin.cpp

    r39708 r41594  
    3030namespace WTF {
    3131
    32 long g_tls_key_count = 0;
    33 DWORD g_tls_keys[kMaxTlsKeySize];
     32long& tlsKeyCount()
     33{
     34    static long count;
     35    return count;
     36}
     37
     38DWORD* tlsKeys()
     39{
     40    static DWORD keys[kMaxTlsKeySize];
     41    return keys;
     42}
    3443
    3544void ThreadSpecificThreadExit()
    3645{
    37     for (long i = 0; i < g_tls_key_count; i++) {
     46    for (long i = 0; i < tlsKeyCount(); i++) {
    3847        // The layout of ThreadSpecific<T>::Data does not depend on T. So we are safe to do the static cast to ThreadSpecific<int> in order to access its data member.
    39         ThreadSpecific<int>::Data* data = static_cast<ThreadSpecific<int>::Data*>(TlsGetValue(g_tls_keys[i]));
     48        ThreadSpecific<int>::Data* data = static_cast<ThreadSpecific<int>::Data*>(TlsGetValue(tlsKeys()[i]));
    4049        if (data)
    4150            data->destructor(data);
Note: See TracChangeset for help on using the changeset viewer.