OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Jian Li <jianli@chromium.org> | 2 * Copyright (C) 2009 Jian Li <jianli@chromium.org> |
3 * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com> | 3 * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com> |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void threadSpecificSet(ThreadSpecificKey key, void* data) { | 100 void threadSpecificSet(ThreadSpecificKey key, void* data) { |
101 key->setValue(data); | 101 key->setValue(data); |
102 } | 102 } |
103 | 103 |
104 void* threadSpecificGet(ThreadSpecificKey key) { | 104 void* threadSpecificGet(ThreadSpecificKey key) { |
105 return key->value(); | 105 return key->value(); |
106 } | 106 } |
107 | 107 |
108 void ThreadSpecificThreadExit() { | 108 void ThreadSpecificThreadExit() { |
109 for (long i = 0; i < tlsKeyCount(); i++) { | 109 for (long i = 0; i < tlsKeyCount(); i++) { |
110 // The layout of ThreadSpecific<T>::Data does not depend on T. So we are saf
e to do the static cast to ThreadSpecific<int> in order to access its data membe
r. | 110 // The layout of ThreadSpecific<T>::Data does not depend on T. So we are |
| 111 // safe to do the static cast to ThreadSpecific<int> in order to access its |
| 112 // data member. |
111 ThreadSpecific<int>::Data* data = | 113 ThreadSpecific<int>::Data* data = |
112 static_cast<ThreadSpecific<int>::Data*>(TlsGetValue(tlsKeys()[i])); | 114 static_cast<ThreadSpecific<int>::Data*>(TlsGetValue(tlsKeys()[i])); |
113 if (data) | 115 if (data) |
114 data->destructor(data); | 116 data->destructor(data); |
115 } | 117 } |
116 | 118 |
117 MutexLocker locker(destructorsMutex()); | 119 MutexLocker locker(destructorsMutex()); |
118 PlatformThreadSpecificKey* key = destructorsList().head(); | 120 PlatformThreadSpecificKey* key = destructorsList().head(); |
119 while (key) { | 121 while (key) { |
120 PlatformThreadSpecificKey* nextKey = key->next(); | 122 PlatformThreadSpecificKey* nextKey = key->next(); |
121 key->callDestructor(); | 123 key->callDestructor(); |
122 key = nextKey; | 124 key = nextKey; |
123 } | 125 } |
124 } | 126 } |
125 | 127 |
126 } // namespace WTF | 128 } // namespace WTF |
127 | 129 |
128 #endif // OS(WIN) | 130 #endif // OS(WIN) |
OLD | NEW |