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

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

Issue 7741018: Remove some unneeded reinterpret_casts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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
« no previous file with comments | « base/string16.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // WARNING: Thread local storage is a bit tricky to get right. Please make 5 // WARNING: Thread local storage is a bit tricky to get right. Please make
6 // sure that this is really the proper solution for what you're trying to 6 // sure that this is really the proper solution for what you're trying to
7 // achieve. Don't prematurely optimize, most likely you can just use a Lock. 7 // achieve. Don't prematurely optimize, most likely you can just use a Lock.
8 // 8 //
9 // These classes implement a wrapper around the platform's TLS storage 9 // These classes implement a wrapper around the platform's TLS storage
10 // mechanism. On construction, they will allocate a TLS slot, and free the 10 // mechanism. On construction, they will allocate a TLS slot, and free the
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 class ThreadLocalBoolean { 107 class ThreadLocalBoolean {
108 public: 108 public:
109 ThreadLocalBoolean() { } 109 ThreadLocalBoolean() { }
110 ~ThreadLocalBoolean() { } 110 ~ThreadLocalBoolean() { }
111 111
112 bool Get() { 112 bool Get() {
113 return tlp_.Get() != NULL; 113 return tlp_.Get() != NULL;
114 } 114 }
115 115
116 void Set(bool val) { 116 void Set(bool val) {
117 tlp_.Set(reinterpret_cast<void*>(val ? 1 : 0)); 117 tlp_.Set(val ? this : NULL);
118 } 118 }
119 119
120 private: 120 private:
121 ThreadLocalPointer<void> tlp_; 121 ThreadLocalPointer<void> tlp_;
122 122
123 DISALLOW_COPY_AND_ASSIGN(ThreadLocalBoolean); 123 DISALLOW_COPY_AND_ASSIGN(ThreadLocalBoolean);
124 }; 124 };
125 125
126 } // namespace base 126 } // namespace base
127 127
128 #endif // BASE_THREADING_THREAD_LOCAL_H_ 128 #endif // BASE_THREADING_THREAD_LOCAL_H_
OLDNEW
« no previous file with comments | « base/string16.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698