Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
LedgerCacheLoadingState.hpp
1#pragma once
2
3#include "data/LedgerCacheInterface.hpp"
4
5#include <atomic>
6#include <functional>
7#include <memory>
8
9namespace data {
10
19public:
20 virtual ~LedgerCacheLoadingStateInterface() = default;
21
25 virtual void
27
32 [[nodiscard]] virtual bool
33 isLoadingAllowed() const = 0;
34
39 virtual void
41
46 [[nodiscard]] virtual bool
47 isCurrentlyLoading() const = 0;
48
55 [[nodiscard]] virtual std::unique_ptr<LedgerCacheLoadingStateInterface>
56 clone() const = 0;
57};
58
66 std::reference_wrapper<LedgerCacheInterface const> cache_;
67 std::shared_ptr<std::atomic_bool> isLoadingAllowed_ = std::make_shared<std::atomic_bool>(false);
68
69public:
74 explicit LedgerCacheLoadingState(LedgerCacheInterface const& cache);
75
77 void
78 allowLoading() override;
79
81 [[nodiscard]] bool
82 isLoadingAllowed() const override;
83
85 void
86 waitForLoadingAllowed() const override;
87
89 [[nodiscard]] bool
90 isCurrentlyLoading() const override;
91
93 [[nodiscard]] std::unique_ptr<LedgerCacheLoadingStateInterface>
94 clone() const override;
95};
96
97} // namespace data
Cache for an entire ledger.
Definition LedgerCacheInterface.hpp:21
Interface for coordinating cache loading permissions across a cluster.
Definition LedgerCacheLoadingState.hpp:18
virtual void waitForLoadingAllowed() const =0
Block until loading is permitted.
virtual std::unique_ptr< LedgerCacheLoadingStateInterface > clone() const =0
Create a clone that shares the same loading-allowed flag.
virtual bool isCurrentlyLoading() const =0
Check whether the cache is currently being loaded from the backend.
virtual bool isLoadingAllowed() const =0
Check whether loading has been permitted.
virtual void allowLoading()=0
Allow this node to begin loading the cache from the backend.
bool isCurrentlyLoading() const override
Check whether the cache is currently being loaded from the backend.
Definition LedgerCacheLoadingState.cpp:33
std::unique_ptr< LedgerCacheLoadingStateInterface > clone() const override
Create a clone that shares the same loading-allowed flag.
Definition LedgerCacheLoadingState.cpp:39
LedgerCacheLoadingState(LedgerCacheInterface const &cache)
Construct a new LedgerCacheLoadingState.
Definition LedgerCacheLoadingState.cpp:9
void allowLoading() override
Allow this node to begin loading the cache from the backend.
Definition LedgerCacheLoadingState.cpp:14
bool isLoadingAllowed() const override
Check whether loading has been permitted.
Definition LedgerCacheLoadingState.cpp:21
void waitForLoadingAllowed() const override
Block until loading is permitted.
Definition LedgerCacheLoadingState.cpp:27
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:56