mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-02 09:52:40 +00:00
feat: Limit cache loading in cluster (#2985)
This PR adds an option to limit simultaneous cache loading in a cluster to one node at a time. Fixes #2707
This commit is contained in:
61
src/data/LedgerCacheLoadingState.cpp
Normal file
61
src/data/LedgerCacheLoadingState.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of clio: https://github.com/XRPLF/clio
|
||||
Copyright (c) 2026, the clio developers.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "data/LedgerCacheLoadingState.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace data {
|
||||
|
||||
LedgerCacheLoadingState::LedgerCacheLoadingState(LedgerCacheInterface const& cache) : cache_(cache)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
LedgerCacheLoadingState::allowLoading()
|
||||
{
|
||||
*isLoadingAllowed_ = true;
|
||||
isLoadingAllowed_->notify_all();
|
||||
}
|
||||
|
||||
bool
|
||||
LedgerCacheLoadingState::isLoadingAllowed() const
|
||||
{
|
||||
return *isLoadingAllowed_;
|
||||
}
|
||||
|
||||
void
|
||||
LedgerCacheLoadingState::waitForLoadingAllowed() const
|
||||
{
|
||||
isLoadingAllowed_->wait(false);
|
||||
}
|
||||
|
||||
bool
|
||||
LedgerCacheLoadingState::isCurrentlyLoading() const
|
||||
{
|
||||
return cache_.get().isCurrentlyLoading();
|
||||
}
|
||||
|
||||
std::unique_ptr<LedgerCacheLoadingStateInterface>
|
||||
LedgerCacheLoadingState::clone() const
|
||||
{
|
||||
return std::make_unique<LedgerCacheLoadingState>(*this);
|
||||
}
|
||||
|
||||
} // namespace data
|
||||
Reference in New Issue
Block a user