rippled
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ripple::NodeStore::BatchWriter Class Reference

Batch-writing assist logic. More...

#include <BatchWriter.h>

Inheritance diagram for ripple::NodeStore::BatchWriter:
Inheritance graph
[legend]
Collaboration diagram for ripple::NodeStore::BatchWriter:
Collaboration graph
[legend]

Classes

struct  Callback
 This callback does the actual writing. More...
 

Public Member Functions

 BatchWriter (Callback &callback, Scheduler &scheduler)
 Create a batch writer.
 
 ~BatchWriter ()
 Destroy a batch writer.
 
void store (std::shared_ptr< NodeObject > const &object)
 Store the object.
 
int getWriteLoad ()
 Get an estimate of the amount of writing I/O pending.
 

Private Types

using LockType = std::recursive_mutex
 
using CondvarType = std::condition_variable_any
 

Private Member Functions

void performScheduledTask () override
 Performs the task.
 
void writeBatch ()
 
void waitForWriting ()
 

Private Attributes

Callbackm_callback
 
Schedulerm_scheduler
 
LockType mWriteMutex
 
CondvarType mWriteCondition
 
int mWriteLoad
 
bool mWritePending
 
Batch mWriteSet
 

Detailed Description

Batch-writing assist logic.

The batch writes are performed with a scheduled task. Use of the class it not required. A backend can implement its own write batching, or skip write batching if doing so yields a performance benefit.

See also
Scheduler

Definition at line 22 of file BatchWriter.h.

Member Typedef Documentation

◆ LockType

Definition at line 68 of file BatchWriter.h.

◆ CondvarType

Definition at line 69 of file BatchWriter.h.

Constructor & Destructor Documentation

◆ BatchWriter()

ripple::NodeStore::BatchWriter::BatchWriter ( Callback callback,
Scheduler scheduler 
)

Create a batch writer.

Definition at line 6 of file BatchWriter.cpp.

◆ ~BatchWriter()

ripple::NodeStore::BatchWriter::~BatchWriter ( )

Destroy a batch writer.

Anything pending in the batch is written out before this returns.

Definition at line 15 of file BatchWriter.cpp.

Member Function Documentation

◆ store()

void ripple::NodeStore::BatchWriter::store ( std::shared_ptr< NodeObject > const &  object)

Store the object.

This will add to the batch and initiate a scheduled task to write the batch out.

Definition at line 21 of file BatchWriter.cpp.

◆ getWriteLoad()

int ripple::NodeStore::BatchWriter::getWriteLoad ( )

Get an estimate of the amount of writing I/O pending.

Definition at line 41 of file BatchWriter.cpp.

◆ performScheduledTask()

void ripple::NodeStore::BatchWriter::performScheduledTask ( )
overrideprivatevirtual

Performs the task.

The call may take place on a foreign thread.

Implements ripple::NodeStore::Task.

Definition at line 49 of file BatchWriter.cpp.

◆ writeBatch()

void ripple::NodeStore::BatchWriter::writeBatch ( )
private

Definition at line 55 of file BatchWriter.cpp.

◆ waitForWriting()

void ripple::NodeStore::BatchWriter::waitForWriting ( )
private

Definition at line 96 of file BatchWriter.cpp.

Member Data Documentation

◆ m_callback

Callback& ripple::NodeStore::BatchWriter::m_callback
private

Definition at line 71 of file BatchWriter.h.

◆ m_scheduler

Scheduler& ripple::NodeStore::BatchWriter::m_scheduler
private

Definition at line 72 of file BatchWriter.h.

◆ mWriteMutex

LockType ripple::NodeStore::BatchWriter::mWriteMutex
private

Definition at line 73 of file BatchWriter.h.

◆ mWriteCondition

CondvarType ripple::NodeStore::BatchWriter::mWriteCondition
private

Definition at line 74 of file BatchWriter.h.

◆ mWriteLoad

int ripple::NodeStore::BatchWriter::mWriteLoad
private

Definition at line 75 of file BatchWriter.h.

◆ mWritePending

bool ripple::NodeStore::BatchWriter::mWritePending
private

Definition at line 76 of file BatchWriter.h.

◆ mWriteSet

Batch ripple::NodeStore::BatchWriter::mWriteSet
private

Definition at line 77 of file BatchWriter.h.