Files
rippled/src/xrpld/app/main/NodeStoreScheduler.cpp
Bart 1eb0fdac65 refactor: Rename ripple namespace to xrpl (#5982)
This change renames all occurrences of `namespace ripple` and `ripple::` to `namespace xrpl` and `xrpl::`, respectively, as well as the names of test suites. It also provides a script to allow developers to replicate the changes in their local branch or fork to avoid conflicts.
2025-12-11 16:51:49 +00:00

48 lines
1.1 KiB
C++

#include <xrpld/app/main/NodeStoreScheduler.h>
namespace xrpl {
NodeStoreScheduler::NodeStoreScheduler(JobQueue& jobQueue) : jobQueue_(jobQueue)
{
}
void
NodeStoreScheduler::scheduleTask(NodeStore::Task& task)
{
if (jobQueue_.isStopped())
return;
if (!jobQueue_.addJob(jtWRITE, "NodeObject::store", [&task]() {
task.performScheduledTask();
}))
{
// Job not added, presumably because we're shutting down.
// Recover by executing the task synchronously.
task.performScheduledTask();
}
}
void
NodeStoreScheduler::onFetch(NodeStore::FetchReport const& report)
{
if (jobQueue_.isStopped())
return;
jobQueue_.addLoadEvents(
report.fetchType == NodeStore::FetchType::async ? jtNS_ASYNC_READ
: jtNS_SYNC_READ,
1,
report.elapsed);
}
void
NodeStoreScheduler::onBatchWrite(NodeStore::BatchWriteReport const& report)
{
if (jobQueue_.isStopped())
return;
jobQueue_.addLoadEvents(jtNS_WRITE, report.writeCount, report.elapsed);
}
} // namespace xrpl