MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / ThreadHandle

Class ThreadHandle

common/Threading.h:54–85  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- ThreadHandle -------------------------------------------------------------------------------------- Abstracts an OS's handle to a thread, closing the handle when necessary. Currently, only used for getting the CPU time for a thread.

Source from the content-addressed store, hash-verified

52 // only used for getting the CPU time for a thread.
53 //
54 class ThreadHandle
55 {
56 public:
57 ThreadHandle();
58 ThreadHandle(ThreadHandle&& handle);
59 ThreadHandle(const ThreadHandle& handle);
60 ~ThreadHandle();
61
62 /// Returns a new handle for the calling thread.
63 static ThreadHandle GetForCallingThread();
64
65 ThreadHandle& operator=(ThreadHandle&& handle);
66 ThreadHandle& operator=(const ThreadHandle& handle);
67
68 operator void*() const { return m_native_handle; }
69 operator bool() const { return (m_native_handle != nullptr); }
70
71 /// Returns the amount of CPU time consumed by the thread, at the GetThreadTicksPerSecond() frequency.
72 u64 GetCPUTime() const;
73
74 /// Sets the affinity for a thread to the specified processors.
75 /// Obviously, only works up to 64 processors.
76 bool SetAffinity(u64 processor_mask) const;
77
78 protected:
79 void* m_native_handle = nullptr;
80
81 // We need the thread ID for affinity adjustments on Linux.
82#if defined(__linux__)
83 unsigned int m_native_id = 0;
84#endif
85 };
86
87 // --------------------------------------------------------------------------------------
88 // Thread

Callers 3

LnxThreads.cppFile · 0.50
DarwinThreads.cppFile · 0.50
WinThreads.cppFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected