File tree Expand file tree Collapse file tree 4 files changed +47
-30
lines changed Expand file tree Collapse file tree 4 files changed +47
-30
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ BITCOIN_CORE_H = \
158
158
compat/endian.h \
159
159
common/settings.h \
160
160
common/system.h \
161
+ common/threadpriority.h \
161
162
compressor.h \
162
163
consensus/consensus.h \
163
164
consensus/tx_check.h \
Original file line number Diff line number Diff line change 13
13
#include < cstdint>
14
14
#include < string>
15
15
16
- #ifndef WIN32
17
- #include < sys/types.h>
18
- #include < sys/time.h>
19
- #include < sys/resource.h>
20
- #endif
21
-
22
16
// Application startup time (used for uptime calculation)
23
17
int64_t GetStartupTime ();
24
18
@@ -37,30 +31,6 @@ void runCommand(const std::string& strCommand);
37
31
*/
38
32
int GetNumCores ();
39
33
40
- #ifdef WIN32
41
- inline void SetThreadPriority (int nPriority)
42
- {
43
- SetThreadPriority (GetCurrentThread (), nPriority);
44
- }
45
- #else
46
-
47
- #define THREAD_PRIORITY_LOWEST PRIO_MAX
48
- #define THREAD_PRIORITY_BELOW_NORMAL 2
49
- #define THREAD_PRIORITY_NORMAL 0
50
- #define THREAD_PRIORITY_ABOVE_NORMAL 0
51
-
52
- inline void SetThreadPriority (int nPriority)
53
- {
54
- // It's unclear if it's even possible to change thread priorities on Linux,
55
- // but we really and truly need it for the generation threads.
56
- #ifdef PRIO_THREAD
57
- setpriority (PRIO_THREAD, 0 , nPriority);
58
- #else
59
- setpriority (PRIO_PROCESS, 0 , nPriority);
60
- #endif
61
- }
62
- #endif
63
-
64
34
bool CheckHex (const std::string& str);
65
35
66
36
#endif // BITCOIN_COMMON_SYSTEM_H
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2024-present The Qtum Core developers
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
5
+ #ifndef QTUM_THREAD_PRIORITY_H
6
+ #define QTUM_THREAD_PRIORITY_H
7
+
8
+ #ifndef WIN32
9
+ #include <sys/types.h>
10
+ #include <sys/time.h>
11
+ #include <sys/resource.h>
12
+ #else
13
+ #include <windows.h>
14
+ #endif
15
+
16
+ #ifdef WIN32
17
+ inline void SetThreadPriority (int nPriority )
18
+ {
19
+ HANDLE hThread = OpenThread (THREAD_ALL_ACCESS , FALSE, GetCurrentThreadId ());
20
+ if (hThread != NULL )
21
+ {
22
+ ::SetThreadPriority (hThread , nPriority );
23
+ CloseHandle (hThread );
24
+ }
25
+ }
26
+ #else
27
+
28
+ #define THREAD_PRIORITY_LOWEST PRIO_MAX
29
+ #define THREAD_PRIORITY_BELOW_NORMAL 2
30
+ #define THREAD_PRIORITY_NORMAL 0
31
+ #define THREAD_PRIORITY_ABOVE_NORMAL 0
32
+
33
+ inline void SetThreadPriority (int nPriority )
34
+ {
35
+ // It's unclear if it's even possible to change thread priorities on Linux,
36
+ // but we really and truly need it for the generation threads.
37
+ #ifdef PRIO_THREAD
38
+ setpriority (PRIO_THREAD , 0 , nPriority );
39
+ #else
40
+ setpriority (PRIO_PROCESS , 0 , nPriority );
41
+ #endif
42
+ }
43
+ #endif
44
+
45
+ #endif // QTUM_THREAD_PRIORITY_H
Original file line number Diff line number Diff line change 9
9
#include < chainparams.h>
10
10
#include < coins.h>
11
11
#include < common/args.h>
12
+ #include < common/threadpriority.h>
12
13
#include < consensus/amount.h>
13
14
#include < consensus/consensus.h>
14
15
#include < consensus/merkle.h>
You can’t perform that action at this time.
0 commit comments