diff options
Diffstat (limited to 'chromium/base/threading/thread_local_storage_posix.cc')
-rw-r--r-- | chromium/base/threading/thread_local_storage_posix.cc | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/chromium/base/threading/thread_local_storage_posix.cc b/chromium/base/threading/thread_local_storage_posix.cc index 75da5a7d8f0..ebaf4005d33 100644 --- a/chromium/base/threading/thread_local_storage_posix.cc +++ b/chromium/base/threading/thread_local_storage_posix.cc @@ -8,42 +8,27 @@ namespace base { -ThreadLocalStorage::Slot::Slot(TLSDestructorFunc destructor) { - initialized_ = false; - key_ = 0; - Initialize(destructor); -} - -bool ThreadLocalStorage::StaticSlot::Initialize(TLSDestructorFunc destructor) { - DCHECK(!initialized_); - int error = pthread_key_create(&key_, destructor); - if (error) { - NOTREACHED(); - return false; - } +namespace internal { - initialized_ = true; - return true; +bool PlatformThreadLocalStorage::AllocTLS(TLSKey* key) { + return !pthread_key_create(key, + base::internal::PlatformThreadLocalStorage::OnThreadExit); } -void ThreadLocalStorage::StaticSlot::Free() { - DCHECK(initialized_); - int error = pthread_key_delete(key_); - if (error) - NOTREACHED(); - initialized_ = false; +void PlatformThreadLocalStorage::FreeTLS(TLSKey key) { + int ret = pthread_key_delete(key); + DCHECK_EQ(ret, 0); } -void* ThreadLocalStorage::StaticSlot::Get() const { - DCHECK(initialized_); - return pthread_getspecific(key_); +void* PlatformThreadLocalStorage::GetTLSValue(TLSKey key) { + return pthread_getspecific(key); } -void ThreadLocalStorage::StaticSlot::Set(void* value) { - DCHECK(initialized_); - int error = pthread_setspecific(key_, value); - if (error) - NOTREACHED(); +void PlatformThreadLocalStorage::SetTLSValue(TLSKey key, void* value) { + int ret = pthread_setspecific(key, value); + DCHECK_EQ(ret, 0); } +} // namespace internal + } // namespace base |