Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
LedgerCacheSaver.hpp
1
#pragma once
2
3
#include "data/LedgerCacheInterface.hpp"
4
#include "util/config/ConfigDefinition.hpp"
5
6
#include <concepts>
7
#include <functional>
8
#include <optional>
9
#include <string>
10
#include <thread>
11
12
namespace
data
{
13
20
template
<
typename
T>
21
concept
SomeLedgerCacheSaver
=
requires
(T a) {
22
{ a.save() } -> std::same_as<void>;
23
{ a.waitToFinish() } -> std::same_as<void>;
24
};
25
33
class
LedgerCacheSaver
{
34
std::optional<std::string> cacheFilePath_;
35
std::reference_wrapper<LedgerCacheInterface const> cache_;
36
std::optional<std::thread> savingThread_;
37
bool
isAsync_;
38
39
public
:
46
LedgerCacheSaver
(
47
util::config::ClioConfigDefinition
const
& config,
48
LedgerCacheInterface
const
& cache
49
);
50
56
~LedgerCacheSaver
();
57
65
void
66
save
();
67
74
void
75
waitToFinish
();
76
};
77
78
}
// namespace data
data::LedgerCacheInterface
Cache for an entire ledger.
Definition
LedgerCacheInterface.hpp:21
data::LedgerCacheSaver::~LedgerCacheSaver
~LedgerCacheSaver()
Destructor that ensures the saving thread is properly joined.
Definition
LedgerCacheSaver.cpp:23
data::LedgerCacheSaver::LedgerCacheSaver
LedgerCacheSaver(util::config::ClioConfigDefinition const &config, LedgerCacheInterface const &cache)
Constructs a LedgerCacheSaver instance.
Definition
LedgerCacheSaver.cpp:13
data::LedgerCacheSaver::waitToFinish
void waitToFinish()
Waits for the saving thread to complete.
Definition
LedgerCacheSaver.cpp:54
data::LedgerCacheSaver::save
void save()
Initiates an asynchronous save operation of the ledger cache.
Definition
LedgerCacheSaver.cpp:29
util::config::ClioConfigDefinition
All the config data will be stored and extracted from this class.
Definition
ConfigDefinition.hpp:31
data::SomeLedgerCacheSaver
A concept for a class that can save ledger cache asynchronously.
Definition
LedgerCacheSaver.hpp:21
data
This namespace implements the data access layer and related components.
Definition
AmendmentCenter.cpp:56
src
data
LedgerCacheSaver.hpp
Generated by
1.17.0