rippled
Public Member Functions | Private Attributes | List of all members
ripple::PendingSaves Class Reference

Keeps track of which ledgers haven't been fully saved. More...

Collaboration diagram for ripple::PendingSaves:
Collaboration graph
[legend]

Public Member Functions

bool startWork (LedgerIndex seq)
 Start working on a ledger. More...
 
void finishWork (LedgerIndex seq)
 Finish working on a ledger. More...
 
bool pending (LedgerIndex seq)
 Return true if a ledger is in the progress of being saved. More...
 
bool shouldWork (LedgerIndex seq, bool isSynchronous)
 Check if a ledger should be dispatched. More...
 
std::map< LedgerIndex, bool > getSnapshot () const
 Get a snapshot of the pending saves. More...
 

Private Attributes

std::mutex mutex_
 
std::map< LedgerIndex, bool > map_
 
std::condition_variable await_
 

Detailed Description

Keeps track of which ledgers haven't been fully saved.

During the ledger building process this collection will keep track of those ledgers that are being built but have not yet been completely written.

Definition at line 36 of file PendingSaves.h.

Member Function Documentation

◆ startWork()

bool ripple::PendingSaves::startWork ( LedgerIndex  seq)

Start working on a ledger.

This is called prior to updating the SQLite indexes.

Returns
'true' if work should be done

Definition at line 51 of file PendingSaves.h.

◆ finishWork()

void ripple::PendingSaves::finishWork ( LedgerIndex  seq)

Finish working on a ledger.

This is called after updating the SQLite indexes. The tracking of the work in progress is removed and threads awaiting completion are notified.

Definition at line 74 of file PendingSaves.h.

◆ pending()

bool ripple::PendingSaves::pending ( LedgerIndex  seq)

Return true if a ledger is in the progress of being saved.

Definition at line 84 of file PendingSaves.h.

◆ shouldWork()

bool ripple::PendingSaves::shouldWork ( LedgerIndex  seq,
bool  isSynchronous 
)

Check if a ledger should be dispatched.

Called to determine whether work should be done or dispatched. If work is already in progress and the call is synchronous, wait for work to be completed.

Returns
'true' if work should be done or dispatched

Definition at line 99 of file PendingSaves.h.

◆ getSnapshot()

std::map<LedgerIndex, bool> ripple::PendingSaves::getSnapshot ( ) const

Get a snapshot of the pending saves.

Each entry in the returned map corresponds to a ledger that is in progress or dispatched. The boolean indicates whether work is currently in progress.

Definition at line 137 of file PendingSaves.h.

Member Data Documentation

◆ mutex_

std::mutex ripple::PendingSaves::mutex_
mutableprivate

Definition at line 39 of file PendingSaves.h.

◆ map_

std::map<LedgerIndex, bool> ripple::PendingSaves::map_
private

Definition at line 40 of file PendingSaves.h.

◆ await_

std::condition_variable ripple::PendingSaves::await_
private

Definition at line 41 of file PendingSaves.h.