| Index: base/threading/thread_local_storage_posix.cc
|
| diff --git a/base/threading/thread_local_storage_posix.cc b/base/threading/thread_local_storage_posix.cc
|
| index 75da5a7d8f0f6e11a8701d808c02dec043bd6af6..00ba6ccdbb6b994bd32947f93a40dffb98321e87 100644
|
| --- a/base/threading/thread_local_storage_posix.cc
|
| +++ b/base/threading/thread_local_storage_posix.cc
|
| @@ -6,44 +6,34 @@
|
|
|
| #include "base/logging.h"
|
|
|
| -namespace base {
|
| +namespace {
|
|
|
| -ThreadLocalStorage::Slot::Slot(TLSDestructorFunc destructor) {
|
| - initialized_ = false;
|
| - key_ = 0;
|
| - Initialize(destructor);
|
| +void OnThreadExitInternal(void* value) {
|
| + base::internal::PlatformThreadLocalStorage::OnThreadExit();
|
| }
|
|
|
| -bool ThreadLocalStorage::StaticSlot::Initialize(TLSDestructorFunc destructor) {
|
| - DCHECK(!initialized_);
|
| - int error = pthread_key_create(&key_, destructor);
|
| - if (error) {
|
| - NOTREACHED();
|
| - return false;
|
| - }
|
| +} // namespace
|
| +
|
| +namespace base {
|
|
|
| - initialized_ = true;
|
| - return true;
|
| +namespace internal {
|
| +
|
| +bool PlatformThreadLocalStorage::AllocTLS(TLSKey* key) {
|
| + return !pthread_key_create(key, OnThreadExitInternal);
|
| }
|
|
|
| -void ThreadLocalStorage::StaticSlot::Free() {
|
| - DCHECK(initialized_);
|
| - int error = pthread_key_delete(key_);
|
| - if (error)
|
| - NOTREACHED();
|
| - initialized_ = false;
|
| +void PlatformThreadLocalStorage::FreeTLS(TLSKey key) {
|
| + DCHECK_EQ(pthread_key_delete(key), 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) {
|
| + DCHECK_EQ(pthread_setspecific(key, value), 0);
|
| }
|
|
|
| +} // namespace internal
|
| +
|
| } // namespace base
|
|
|