Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Unified Diff: base/threading/thread_local.h

Issue 139633003: Switch thread_local to use chromium's TLS implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/base.gypi ('k') | base/threading/thread_local_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>);
};
« no previous file with comments | « base/base.gypi ('k') | base/threading/thread_local_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698