Debian Codegraph @

Source/Core/Common/Thread.h

raw symbols SCIP
1 // Copyright 2008 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <thread>
7
8 #ifndef _WIN32
9 #include <tuple>
10 #endif
11
12 // Don't include Common.h here as it will break LogManager
13 #include "Common/CommonTypes.h"
14
15 // This may not be defined outside _WIN32
16 #ifndef _WIN32
17 #ifndef INFINITE
18 #define INFINITE 0xffffffff
19 #endif
20 #endif
21
22 namespace Common
23 {
24 int CurrentThreadId();
25
26 void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask);
27 void SetCurrentThreadAffinity(u32 mask);
28
29 void SleepCurrentThread(int ms);
30 void SwitchCurrentThread(); // On Linux, this is equal to sleep 1ms
31
32 // Use this function during a spin-wait to make the current thread
33 // relax while another thread is working. This may be more efficient
34 // than using events because event functions use kernel calls.
35 inline void YieldCPU()
36 {
37 std::this_thread::yield();
38 }
39
40 void SetCurrentThreadName(const char* name);
41
42 #ifndef _WIN32
43 // Returns the lowest address of the stack and the size of the stack
44 std::tuple<void*, size_t> GetCurrentThreadStack();
45 #endif
46
47 } // namespace Common