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

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

Issue 11438022: Add ability to retrieve a thread_name given a thread_id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move the set to PlatformThread::SetName so we catch any name changes. Created 8 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
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698