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

Side by Side Diff: base/threading/thread_local_storage.h

Issue 8702014: Make ThreadLocalStorage more posix pthread compliant (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef BASE_THREADING_THREAD_LOCAL_STORAGE_H_ 5 #ifndef BASE_THREADING_THREAD_LOCAL_STORAGE_H_
6 #define BASE_THREADING_THREAD_LOCAL_STORAGE_H_ 6 #define BASE_THREADING_THREAD_LOCAL_STORAGE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/atomicops.h"
9 #include "base/base_export.h" 10 #include "base/base_export.h"
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 12
12 #if defined(OS_POSIX) 13 #if defined(OS_POSIX)
13 #include <pthread.h> 14 #include <pthread.h>
14 #endif 15 #endif
15 16
16 namespace base { 17 namespace base {
17 18
18 // Wrapper for thread local storage. This class doesn't do much except provide 19 // Wrapper for thread local storage. This class doesn't do much except provide
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Function called when on thread exit to call TLS 73 // Function called when on thread exit to call TLS
73 // destructor functions. This function is used internally. 74 // destructor functions. This function is used internally.
74 static void ThreadExit(); 75 static void ThreadExit();
75 76
76 private: 77 private:
77 // Function to lazily initialize our thread local storage. 78 // Function to lazily initialize our thread local storage.
78 static void **Initialize(); 79 static void **Initialize();
79 80
80 private: 81 private:
81 // The maximum number of 'slots' in our thread local storage stack. 82 // The maximum number of 'slots' in our thread local storage stack.
82 // For now, this is fixed. We could either increase statically, or
83 // we could make it dynamic in the future.
84 static const int kThreadLocalStorageSize = 64; 83 static const int kThreadLocalStorageSize = 64;
85 84
85 // The maximum number of times to try to clear slots by caling destructors.
willchan no longer on Chromium 2011/11/29 01:46:49 s/caling/calling/
jar (doing other things) 2011/11/29 02:32:45 Done.
86 // Use pthread naming convention for clarity.
87 static const int PTHREAD_DESTRUCTOR_ITERATIONS = kThreadLocalStorageSize;
rvargas (doing something else) 2011/11/29 01:26:31 I don't see why we want to expose this value in th
jar (doing other things) 2011/11/29 02:32:45 Done.
88
86 static long tls_key_; 89 static long tls_key_;
87 static long tls_max_; 90 static long tls_max_;
88 static TLSDestructorFunc tls_destructors_[kThreadLocalStorageSize]; 91 static subtle::AtomicWord tls_destructors_[kThreadLocalStorageSize];
89 #endif // OS_WIN 92 #endif // OS_WIN
90 93
91 DISALLOW_COPY_AND_ASSIGN(ThreadLocalStorage); 94 DISALLOW_COPY_AND_ASSIGN(ThreadLocalStorage);
92 }; 95 };
93 96
94 } // namespace base 97 } // namespace base
95 98
96 #endif // BASE_THREADING_THREAD_LOCAL_STORAGE_H_ 99 #endif // BASE_THREADING_THREAD_LOCAL_STORAGE_H_
OLDNEW
« no previous file with comments | « no previous file | base/threading/thread_local_storage_unittest.cc » ('j') | base/threading/thread_local_storage_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698