mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
refactor: Move ScheduleBatchPriority to its own file
With the previous move of AlertNotify out of the validation file, and thus out of the kernel library, ScheduleBatchPriority is the last remaining function used by the kernel library from util/system. Move it to its own file, such that util/system can be moved out of the util library in the following few commits. Moving util/system out of the kernel library removes further networking as well as shell related code from it.
This commit is contained in:
parent
f871c69191
commit
9ec5da36b6
@ -280,6 +280,7 @@ BITCOIN_CORE_H = \
|
||||
txrequest.h \
|
||||
undo.h \
|
||||
util/asmap.h \
|
||||
util/batchpriority.h \
|
||||
util/bip32.h \
|
||||
util/bitdeque.h \
|
||||
util/bytevectorhash.h \
|
||||
@ -711,6 +712,7 @@ libbitcoin_util_a_SOURCES = \
|
||||
support/cleanse.cpp \
|
||||
sync.cpp \
|
||||
util/asmap.cpp \
|
||||
util/batchpriority.cpp \
|
||||
util/bip32.cpp \
|
||||
util/bytevectorhash.cpp \
|
||||
util/chaintype.cpp \
|
||||
@ -963,6 +965,7 @@ libbitcoinkernel_la_SOURCES = \
|
||||
txdb.cpp \
|
||||
txmempool.cpp \
|
||||
uint256.cpp \
|
||||
util/batchpriority.cpp \
|
||||
util/chaintype.cpp \
|
||||
util/check.cpp \
|
||||
util/exception.cpp \
|
||||
@ -978,7 +981,6 @@ libbitcoinkernel_la_SOURCES = \
|
||||
util/string.cpp \
|
||||
util/syscall_sandbox.cpp \
|
||||
util/syserror.cpp \
|
||||
util/system.cpp \
|
||||
util/thread.cpp \
|
||||
util/threadnames.cpp \
|
||||
util/time.cpp \
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <signet.h>
|
||||
#include <streams.h>
|
||||
#include <undo.h>
|
||||
#include <util/batchpriority.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/syscall_sandbox.h>
|
||||
#include <util/system.h>
|
||||
|
26
src/util/batchpriority.cpp
Normal file
26
src/util/batchpriority.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2023 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <logging.h>
|
||||
#include <util/syserror.h>
|
||||
|
||||
#if (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
|
||||
#include <pthread.h>
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
void ScheduleBatchPriority()
|
||||
{
|
||||
#ifdef SCHED_BATCH
|
||||
const static sched_param param{};
|
||||
const int rc = pthread_setschedparam(pthread_self(), SCHED_BATCH, ¶m);
|
||||
if (rc != 0) {
|
||||
LogPrintf("Failed to pthread_setschedparam: %s\n", SysErrorString(rc));
|
||||
}
|
||||
#endif
|
||||
}
|
15
src/util/batchpriority.h
Normal file
15
src/util/batchpriority.h
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) 2023 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_UTIL_BATCHPRIORITY_H
|
||||
#define BITCOIN_UTIL_BATCHPRIORITY_H
|
||||
|
||||
/**
|
||||
* On platforms that support it, tell the kernel the calling thread is
|
||||
* CPU-intensive and non-interactive. See SCHED_BATCH in sched(7) for details.
|
||||
*
|
||||
*/
|
||||
void ScheduleBatchPriority();
|
||||
|
||||
#endif // BITCOIN_UTIL_BATCHPRIORITY_H
|
@ -7,16 +7,9 @@
|
||||
|
||||
#include <logging.h>
|
||||
#include <util/string.h>
|
||||
#include <util/syserror.h>
|
||||
#include <util/time.h>
|
||||
|
||||
#if (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
|
||||
#include <pthread.h>
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sched.h>
|
||||
#include <sys/stat.h>
|
||||
#else
|
||||
#include <codecvt>
|
||||
@ -112,14 +105,3 @@ int64_t GetStartupTime()
|
||||
{
|
||||
return nStartupTime;
|
||||
}
|
||||
|
||||
void ScheduleBatchPriority()
|
||||
{
|
||||
#ifdef SCHED_BATCH
|
||||
const static sched_param param{};
|
||||
const int rc = pthread_setschedparam(pthread_self(), SCHED_BATCH, ¶m);
|
||||
if (rc != 0) {
|
||||
LogPrintf("Failed to pthread_setschedparam: %s\n", SysErrorString(rc));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -36,13 +36,6 @@ void runCommand(const std::string& strCommand);
|
||||
*/
|
||||
int GetNumCores();
|
||||
|
||||
/**
|
||||
* On platforms that support it, tell the kernel the calling thread is
|
||||
* CPU-intensive and non-interactive. See SCHED_BATCH in sched(7) for details.
|
||||
*
|
||||
*/
|
||||
void ScheduleBatchPriority();
|
||||
|
||||
namespace util {
|
||||
|
||||
//! Simplification of std insertion
|
||||
|
Loading…
Reference in New Issue
Block a user