20 #include <ripple/basics/contract.h>
21 #include <ripple/core/Stoppable.h>
28 : m_name (
std::move (name))
35 : m_name (
std::move (name))
36 , m_root (parent.m_root)
101 iter->stoppable->prepareRecursive ();
110 iter->stoppable->startRecursive ();
119 iter->stoppable->stopAsyncRecursive(j);
128 iter->stoppable->stopRecursive (j);
137 using namespace std::chrono_literals;
139 if (!
m_cv.
wait_for(lk, 1s, [
this]{return m_is_stopping;}))
141 if (
auto stream = j.
error())
142 stream <<
"Waiting for '" <<
m_name <<
"' to stop";
157 using namespace std::chrono_literals;
204 if (
auto stream = j.
warn())
205 stream <<
"Stoppable::stop called again";
210 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.