-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
timemarkovqtum
committed
Sep 17, 2024
1 parent
90612c8
commit aab151d
Showing
4 changed files
with
47 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2024-present The Qtum Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef QTUM_THREAD_PRIORITY_H | ||
#define QTUM_THREAD_PRIORITY_H | ||
|
||
#ifndef WIN32 | ||
#include <sys/types.h> | ||
#include <sys/time.h> | ||
#include <sys/resource.h> | ||
#else | ||
#include <windows.h> | ||
#endif | ||
|
||
#ifdef WIN32 | ||
inline void SetThreadPriority(int nPriority) | ||
{ | ||
HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, GetCurrentThreadId()); | ||
if (hThread != NULL) | ||
{ | ||
::SetThreadPriority(hThread, nPriority); | ||
CloseHandle(hThread); | ||
} | ||
} | ||
#else | ||
|
||
#define THREAD_PRIORITY_LOWEST PRIO_MAX | ||
#define THREAD_PRIORITY_BELOW_NORMAL 2 | ||
#define THREAD_PRIORITY_NORMAL 0 | ||
#define THREAD_PRIORITY_ABOVE_NORMAL 0 | ||
|
||
inline void SetThreadPriority(int nPriority) | ||
{ | ||
// It's unclear if it's even possible to change thread priorities on Linux, | ||
// but we really and truly need it for the generation threads. | ||
#ifdef PRIO_THREAD | ||
setpriority(PRIO_THREAD, 0, nPriority); | ||
#else | ||
setpriority(PRIO_PROCESS, 0, nPriority); | ||
#endif | ||
} | ||
#endif | ||
|
||
#endif // QTUM_THREAD_PRIORITY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters