aboutsummaryrefslogtreecommitdiff
path: root/src/scheduler.h
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-05-11 17:18:17 +0200
committerMacroFake <falke.marco@gmail.com>2022-05-11 17:18:25 +0200
commit9db941d7737406b8593024ba130c3f9c186af4c6 (patch)
tree3fea801cfe2079a24df2b9743c807f3df369edc1 /src/scheduler.h
parentcca900e3820d6d5e765a3532c2211bc3412f3729 (diff)
parentfa9051642269f62f560af3f323fbf36cb7b58082 (diff)
downloadbitcoin-9db941d7737406b8593024ba130c3f9c186af4c6.tar.xz
Merge bitcoin/bitcoin#25100: Switch scheduler to steady_clock
fa9051642269f62f560af3f323fbf36cb7b58082 Switch scheduler to steady_clock (MacroFake) Pull request description: There is already `mockscheduler`, so it seems brittle, confusing and redundant to be able to mock the scheduler by adjusting the system clock. ACKs for top commit: laanwj: Code review ACK fa9051642269f62f560af3f323fbf36cb7b58082 w0xlt: crACK https://github.com/bitcoin/bitcoin/pull/25100/commits/fa9051642269f62f560af3f323fbf36cb7b58082 Tree-SHA512: 60e99065ffb881a9fb25a346d311d99424fbc72a3b636c94b5f5c17ed6373c40f358a9b27825c518d12968c033e6cfd3c62d2b62cacdddc44a0b5b74f6c1a7ae
Diffstat (limited to 'src/scheduler.h')
-rw-r--r--src/scheduler.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/scheduler.h b/src/scheduler.h
index eb350e4bc3..b8245f97ed 100644
--- a/src/scheduler.h
+++ b/src/scheduler.h
@@ -46,12 +46,12 @@ public:
typedef std::function<void()> Function;
/** Call func at/after time t */
- void schedule(Function f, std::chrono::system_clock::time_point t);
+ void schedule(Function f, std::chrono::steady_clock::time_point t);
/** Call f once after the delta has passed */
void scheduleFromNow(Function f, std::chrono::milliseconds delta)
{
- schedule(std::move(f), std::chrono::system_clock::now() + delta);
+ schedule(std::move(f), std::chrono::steady_clock::now() + delta);
}
/**
@@ -93,8 +93,8 @@ public:
* Returns number of tasks waiting to be serviced,
* and first and last task times
*/
- size_t getQueueInfo(std::chrono::system_clock::time_point& first,
- std::chrono::system_clock::time_point& last) const;
+ size_t getQueueInfo(std::chrono::steady_clock::time_point& first,
+ std::chrono::steady_clock::time_point& last) const;
/** Returns true if there are threads actively running in serviceQueue() */
bool AreThreadsServicingQueue() const;
@@ -102,7 +102,7 @@ public:
private:
mutable Mutex newTaskMutex;
std::condition_variable newTaskScheduled;
- std::multimap<std::chrono::system_clock::time_point, Function> taskQueue GUARDED_BY(newTaskMutex);
+ std::multimap<std::chrono::steady_clock::time_point, Function> taskQueue GUARDED_BY(newTaskMutex);
int nThreadsServicingQueue GUARDED_BY(newTaskMutex){0};
bool stopRequested GUARDED_BY(newTaskMutex){false};
bool stopWhenEmpty GUARDED_BY(newTaskMutex){false};