mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 18:45:52 +00:00
Per XLS-0095, we are taking steps to rename ripple(d) to xrpl(d). This change specifically removes all copyright notices referencing Ripple, XRPLF, and certain affiliated contributors upon mutual agreement, so the notice in the LICENSE.md file applies throughout. Copyright notices referencing external contributions remain as-is. Duplicate verbiage is also removed.
72 lines
1.6 KiB
C++
72 lines
1.6 KiB
C++
#ifndef XRPL_NODESTORE_SCHEDULER_H_INCLUDED
|
|
#define XRPL_NODESTORE_SCHEDULER_H_INCLUDED
|
|
|
|
#include <xrpl/nodestore/Task.h>
|
|
|
|
#include <chrono>
|
|
|
|
namespace ripple {
|
|
namespace NodeStore {
|
|
|
|
enum class FetchType { synchronous, async };
|
|
|
|
/** Contains information about a fetch operation. */
|
|
struct FetchReport
|
|
{
|
|
explicit FetchReport(FetchType fetchType_) : fetchType(fetchType_)
|
|
{
|
|
}
|
|
|
|
std::chrono::milliseconds elapsed;
|
|
FetchType const fetchType;
|
|
bool wasFound = false;
|
|
};
|
|
|
|
/** Contains information about a batch write operation. */
|
|
struct BatchWriteReport
|
|
{
|
|
explicit BatchWriteReport() = default;
|
|
|
|
std::chrono::milliseconds elapsed;
|
|
int writeCount;
|
|
};
|
|
|
|
/** Scheduling for asynchronous backend activity
|
|
|
|
For improved performance, a backend has the option of performing writes
|
|
in batches. These writes can be scheduled using the provided scheduler
|
|
object.
|
|
|
|
@see BatchWriter
|
|
*/
|
|
class Scheduler
|
|
{
|
|
public:
|
|
virtual ~Scheduler() = default;
|
|
|
|
/** Schedules a task.
|
|
Depending on the implementation, the task may be invoked either on
|
|
the current thread of execution, or an unspecified
|
|
implementation-defined foreign thread.
|
|
*/
|
|
virtual void
|
|
scheduleTask(Task& task) = 0;
|
|
|
|
/** Reports completion of a fetch
|
|
Allows the scheduler to monitor the node store's performance
|
|
*/
|
|
virtual void
|
|
onFetch(FetchReport const& report) = 0;
|
|
|
|
/** Reports the completion of a batch write
|
|
Allows the scheduler to monitor the node store's performance
|
|
*/
|
|
virtual void
|
|
onBatchWrite(BatchWriteReport const& report) = 0;
|
|
};
|
|
|
|
} // namespace NodeStore
|
|
} // namespace ripple
|
|
|
|
#endif
|