HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
threads.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 
8 #ifndef PXR_BASE_TRACE_THREADS_H
9 #define PXR_BASE_TRACE_THREADS_H
10 
11 #include "pxr/pxr.h"
12 #include "pxr/base/trace/api.h"
13 
14 #include <string>
15 
17 
18 ////////////////////////////////////////////////////////////////////////////////
19 /// \class TraceThreadId
20 ///
21 /// This class represents an identifier for a thread.
22 ///
24 public:
25  /// Constructor which creates an identifier based on std::thread_id. .
26  /// It is either"Main Thread" if this id is marked as the main thread or
27  /// "Thread XXX" where XXX is the string representation of the thread id.
29 
30  /// Constructor which creates an identifier from \p id.
31  TRACE_API explicit TraceThreadId(const std::string& id);
32 
33  /// Returns the string representation of the id.
34  const std::string& ToString() const { return _id; }
35 
36  /// Equality operator.
37  TRACE_API bool operator==(const TraceThreadId&) const;
38 
39  /// Less than operator.
40  TRACE_API bool operator<(const TraceThreadId&) const;
41 private:
42  std::string _id;
43 };
44 
46  return TraceThreadId();
47 }
48 
50 
51 #endif // PXR_BASE_TRACE_THREADS_H
TraceThreadId TraceGetThreadId()
Definition: threads.h:45
const std::string & ToString() const
Returns the string representation of the id.
Definition: threads.h:34
TRACE_API TraceThreadId()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
TRACE_API bool operator<(const TraceThreadId &) const
Less than operator.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
TRACE_API bool operator==(const TraceThreadId &) const
Equality operator.
#define TRACE_API
Definition: api.h:23