20 #include <ripple/basics/contract.h>
21 #include <ripple/core/Stoppable.h>
28 : m_name(
std::move(name)), m_root(root), m_child(this)
33 : m_name(
std::move(name)), m_root(parent.m_root), m_child(this)
108 iter->stoppable->prepareRecursive();
119 iter->stoppable->startRecursive();
130 iter->stoppable->stopAsyncRecursive(j);
141 iter->stoppable->stopRecursive(j);
150 using namespace std::chrono_literals;
152 if (!
m_cv.
wait_for(lk, 1s, [
this] { return m_is_stopping; }))
154 if (
auto stream = j.
error())
155 stream <<
"Waiting for '" <<
m_name <<
"' to stop";
170 using namespace std::chrono_literals;
222 if (
auto stream = j.
warn())
223 stream <<
"Stoppable::stop called again";
228 using namespace std::chrono_literals;
virtual ~Stoppable()
Destroy the Stoppable.
bool stopAsync(beast::Journal j)
std::atomic< bool > m_prepared
std::atomic< bool > m_stopped
void stopped()
Called by derived classes to indicate that the stoppable has stopped.
virtual void onStop()
Override called when the stop notification is issued.
const_iterator cbegin() const
Stoppable(std::string name, RootStoppable &root)
virtual void onStart()
Override called during start.
beast::Journal debugLog()
Returns a debug journal.
void setParent(Stoppable &parent)
Set the parent of this Stoppable.
void prepare()
Prepare all contained Stoppable objects.
void stopAsyncRecursive(beast::Journal j)
void stop(beast::Journal j)
Notify a root stoppable and children to stop, and block until stopped.
bool isStopped() const
Returns true if the requested stop has completed.
Provides an interface for starting and stopping.
virtual void onPrepare()
Override called during preparation.
bool areChildrenStopped() const
Returns true if all children have stopped.
std::condition_variable m_cv
std::atomic< bool > m_calledStop
A generic endpoint for log messages.
void stopRecursive(beast::Journal j)
std::atomic< bool > m_started
friend class RootStoppable
void start()
Start all contained Stoppable objects.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::atomic< bool > m_childrenStopped
virtual void onChildrenStopped()
Override called when all children have stopped.
void join(char const *name, std::chrono::milliseconds wait, beast::Journal j)
Returns once all counted in-flight closures are destroyed.
bool push_front(Node *node)
Push a node onto the stack.
std::condition_variable c_
const_iterator cend() const
bool isStopping() const
Returns true if the stoppable should stop.