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

Unified Diff: trunk/src/base/threading/thread_local_storage_posix.cc

Issue 121393002: Revert 241657 "Implement chromium's TLS." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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
Index: trunk/src/base/threading/thread_local_storage_posix.cc
===================================================================
--- trunk/src/base/threading/thread_local_storage_posix.cc (revision 242548)
+++ trunk/src/base/threading/thread_local_storage_posix.cc (working copy)
@@ -8,27 +8,42 @@
namespace base {
-namespace internal {
+ThreadLocalStorage::Slot::Slot(TLSDestructorFunc destructor) {
+ initialized_ = false;
+ key_ = 0;
+ Initialize(destructor);
+}
-bool PlatformThreadLocalStorage::AllocTLS(TLSKey* key) {
- return !pthread_key_create(key,
- base::internal::PlatformThreadLocalStorage::OnThreadExit);
+bool ThreadLocalStorage::StaticSlot::Initialize(TLSDestructorFunc destructor) {
+ DCHECK(!initialized_);
+ int error = pthread_key_create(&key_, destructor);
+ if (error) {
+ NOTREACHED();
+ return false;
+ }
+
+ initialized_ = true;
+ return true;
}
-void PlatformThreadLocalStorage::FreeTLS(TLSKey key) {
- int ret = pthread_key_delete(key);
- DCHECK_EQ(ret, 0);
+void ThreadLocalStorage::StaticSlot::Free() {
+ DCHECK(initialized_);
+ int error = pthread_key_delete(key_);
+ if (error)
+ NOTREACHED();
+ initialized_ = false;
}
-void* PlatformThreadLocalStorage::GetTLSValue(TLSKey key) {
- return pthread_getspecific(key);
+void* ThreadLocalStorage::StaticSlot::Get() const {
+ DCHECK(initialized_);
+ return pthread_getspecific(key_);
}
-void PlatformThreadLocalStorage::SetTLSValue(TLSKey key, void* value) {
- int ret = pthread_setspecific(key, value);
- DCHECK_EQ(ret, 0);
+void ThreadLocalStorage::StaticSlot::Set(void* value) {
+ DCHECK(initialized_);
+ int error = pthread_setspecific(key_, value);
+ if (error)
+ NOTREACHED();
}
-} // namespace internal
-
} // namespace base
« no previous file with comments | « trunk/src/base/threading/thread_local_storage.cc ('k') | trunk/src/base/threading/thread_local_storage_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698