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

Side by Side 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 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/threading/thread_local_storage.h" 5 #include "base/threading/thread_local_storage.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace base { 9 namespace base {
10 10
11 namespace internal { 11 ThreadLocalStorage::Slot::Slot(TLSDestructorFunc destructor) {
12 12 initialized_ = false;
13 bool PlatformThreadLocalStorage::AllocTLS(TLSKey* key) { 13 key_ = 0;
14 return !pthread_key_create(key, 14 Initialize(destructor);
15 base::internal::PlatformThreadLocalStorage::OnThreadExit);
16 } 15 }
17 16
18 void PlatformThreadLocalStorage::FreeTLS(TLSKey key) { 17 bool ThreadLocalStorage::StaticSlot::Initialize(TLSDestructorFunc destructor) {
19 int ret = pthread_key_delete(key); 18 DCHECK(!initialized_);
20 DCHECK_EQ(ret, 0); 19 int error = pthread_key_create(&key_, destructor);
20 if (error) {
21 NOTREACHED();
22 return false;
23 }
24
25 initialized_ = true;
26 return true;
21 } 27 }
22 28
23 void* PlatformThreadLocalStorage::GetTLSValue(TLSKey key) { 29 void ThreadLocalStorage::StaticSlot::Free() {
24 return pthread_getspecific(key); 30 DCHECK(initialized_);
31 int error = pthread_key_delete(key_);
32 if (error)
33 NOTREACHED();
34 initialized_ = false;
25 } 35 }
26 36
27 void PlatformThreadLocalStorage::SetTLSValue(TLSKey key, void* value) { 37 void* ThreadLocalStorage::StaticSlot::Get() const {
28 int ret = pthread_setspecific(key, value); 38 DCHECK(initialized_);
29 DCHECK_EQ(ret, 0); 39 return pthread_getspecific(key_);
30 } 40 }
31 41
32 } // namespace internal 42 void ThreadLocalStorage::StaticSlot::Set(void* value) {
43 DCHECK(initialized_);
44 int error = pthread_setspecific(key_, value);
45 if (error)
46 NOTREACHED();
47 }
33 48
34 } // namespace base 49 } // namespace base
OLDNEW
« 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