| Index: base/threading/thread_local.h
|
| diff --git a/base/threading/thread_local.h b/base/threading/thread_local.h
|
| index b13be1ab4678584d871147f928d6b839fe37e57d..ec8ce49212773165484ff3d83f7cb252762e49b9 100644
|
| --- a/base/threading/thread_local.h
|
| +++ b/base/threading/thread_local.h
|
| @@ -50,55 +50,27 @@
|
|
|
| #include "base/base_export.h"
|
| #include "base/basictypes.h"
|
| -
|
| -#if defined(OS_POSIX)
|
| -#include <pthread.h>
|
| -#endif
|
| +#include "base/threading/thread_local_storage.h"
|
|
|
| namespace base {
|
| -namespace internal {
|
| -
|
| -// Helper functions that abstract the cross-platform APIs. Do not use directly.
|
| -struct BASE_EXPORT ThreadLocalPlatform {
|
| -#if defined(OS_WIN)
|
| - typedef unsigned long SlotType;
|
| -#elif defined(OS_POSIX)
|
| - typedef pthread_key_t SlotType;
|
| -#endif
|
| -
|
| - static void AllocateSlot(SlotType* slot);
|
| - static void FreeSlot(SlotType slot);
|
| - static void* GetValueFromSlot(SlotType slot);
|
| - static void SetValueInSlot(SlotType slot, void* value);
|
| -};
|
| -
|
| -} // namespace internal
|
|
|
| template <typename Type>
|
| class ThreadLocalPointer {
|
| public:
|
| - ThreadLocalPointer() : slot_() {
|
| - internal::ThreadLocalPlatform::AllocateSlot(&slot_);
|
| - }
|
| + ThreadLocalPointer() {}
|
|
|
| - ~ThreadLocalPointer() {
|
| - internal::ThreadLocalPlatform::FreeSlot(slot_);
|
| - }
|
| + ~ThreadLocalPointer() {}
|
|
|
| Type* Get() {
|
| - return static_cast<Type*>(
|
| - internal::ThreadLocalPlatform::GetValueFromSlot(slot_));
|
| + return static_cast<Type*>(slot_.Get());
|
| }
|
|
|
| void Set(Type* ptr) {
|
| - internal::ThreadLocalPlatform::SetValueInSlot(
|
| - slot_, const_cast<void*>(static_cast<const void*>(ptr)));
|
| + slot_.Set(const_cast<void*>(static_cast<const void*>(ptr)));
|
| }
|
|
|
| private:
|
| - typedef internal::ThreadLocalPlatform::SlotType SlotType;
|
| -
|
| - SlotType slot_;
|
| + ThreadLocalStorage::Slot slot_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ThreadLocalPointer<Type>);
|
| };
|
|
|