xrpld
Loading...
Searching...
No Matches
NodeStoreScheduler.cpp
1#include <xrpld/app/main/NodeStoreScheduler.h>
2
3#include <xrpl/core/Job.h>
4#include <xrpl/core/JobQueue.h>
5#include <xrpl/nodestore/Scheduler.h>
6#include <xrpl/nodestore/Task.h>
7
8namespace xrpl {
9
13
14void
16{
17 if (jobQueue_.isStopped())
18 return;
19
20 if (!jobQueue_.addJob(JtWrite, "NObjStore", [&task]() { task.performScheduledTask(); }))
21 {
22 // Job not added, presumably because we're shutting down.
23 // Recover by executing the task synchronously.
25 }
26}
27
28void
30{
31 if (jobQueue_.isStopped())
32 return;
33
34 jobQueue_.addLoadEvents(
36 1,
37 report.elapsed);
38}
39
40void
42{
43 if (jobQueue_.isStopped())
44 return;
45
46 jobQueue_.addLoadEvents(JtNsWrite, report.writeCount, report.elapsed);
47}
48
49} // namespace xrpl
A pool of threads to perform work.
Definition JobQueue.h:43
NodeStoreScheduler(JobQueue &jobQueue)
void onBatchWrite(NodeStore::BatchWriteReport const &report) override
Reports the completion of a batch write Allows the scheduler to monitor the node store's performance.
void scheduleTask(NodeStore::Task &task) override
Schedules a task.
void onFetch(NodeStore::FetchReport const &report) override
Reports completion of a fetch Allows the scheduler to monitor the node store's performance.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ JtNsWrite
Definition Job.h:73
@ JtWrite
Definition Job.h:53
@ JtNsAsyncRead
Definition Job.h:72
@ JtNsSyncRead
Definition Job.h:71
Contains information about a batch write operation.
Contains information about a fetch operation.
Derived classes perform scheduled tasks.
Definition Task.h:7
virtual void performScheduledTask()=0
Performs the task.