OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_THREADING_THREAD_ID_NAME_MANAGER_H_ | |
6 #define BASE_THREADING_THREAD_ID_NAME_MANAGER_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/base_export.h" | |
12 #include "base/basictypes.h" | |
13 #include "base/synchronization/lock.h" | |
14 #include "base/threading/platform_thread.h" | |
15 | |
16 template <typename T> struct DefaultSingletonTraits; | |
jonathan.backer
2012/12/05 20:06:12
Different traits define kAllowedToAccessOnNonjoina
dsinclair
2012/12/05 20:40:09
Switched to LeakySingletonTraits.
| |
17 | |
18 namespace base { | |
19 | |
20 class BASE_EXPORT ThreadIdNameManager { | |
21 public: | |
22 static ThreadIdNameManager* GetInstance(); | |
23 | |
24 bool GetNameForId(PlatformThreadId id, std::string* name); | |
25 void SetNameForId(PlatformThreadId id, std::string name); | |
26 void RemoveNameForId(PlatformThreadId id); | |
27 | |
28 private: | |
29 friend struct DefaultSingletonTraits<ThreadIdNameManager>; | |
30 | |
31 ThreadIdNameManager(); | |
32 ~ThreadIdNameManager(); | |
33 | |
34 // protectes id_to_name_ | |
35 base::Lock lock_; | |
36 | |
37 std::map<PlatformThreadId, std::string> id_to_name_; | |
38 | |
39 DISALLOW_COPY_AND_ASSIGN(ThreadIdNameManager); | |
40 }; | |
41 | |
42 } // namespace base | |
43 | |
44 #endif // BASE_THREADING_THREAD_ID_NAME_MANAGER_H_ | |
OLD | NEW |