1#ifndef XRPL_CORE_CLOSURE_COUNTER_H_INCLUDED 
    2#define XRPL_CORE_CLOSURE_COUNTER_H_INCLUDED 
    4#include <xrpl/basics/Log.h> 
   34template <
typename Ret_t, 
typename... Args_t>
 
   71    template <
typename Closure>
 
   81            "Closure arguments don't match ClosureCounter Ret_t or Args_t");
 
 
  136        using namespace std::chrono_literals;
 
 
  154                    lock, wait, [
this] { return closureCount_ == 0; }))
 
  156                if (
auto stream = j.
error())
 
  157                    stream << name << 
" waiting for ClosureCounter::join().";
 
 
  171    template <
class Closure>
 
 
A generic endpoint for log messages.
 
Substitute(Substitute const &rhs)
 
Substitute(Substitute &&rhs) noexcept(std::is_nothrow_move_constructible< Closure >::value)
 
std::remove_reference_t< Closure > closure_
 
Substitute & operator=(Substitute const &rhs)=delete
 
Substitute & operator=(Substitute &&rhs)=delete
 
Ret_t operator()(Args_t... args)
 
ClosureCounter & counter_
 
Substitute(ClosureCounter &counter, Closure &&closure)
 
The role of a ClosureCounter is to assist in shutdown by letting callers wait for the completion of c...
 
bool joined() const
Returns true if this has been joined.
 
std::optional< Substitute< Closure > > wrap(Closure &&closure)
Wrap the passed closure with a reference counter.
 
ClosureCounter & operator++()
 
ClosureCounter(ClosureCounter const &)=delete
 
std::atomic< int > closureCount_
 
ClosureCounter & operator--()
 
int count() const
Current number of Closures outstanding.
 
ClosureCounter & operator=(ClosureCounter const &)=delete
 
~ClosureCounter()
Destructor verifies all in-flight closures are complete.
 
std::condition_variable allClosuresDoneCond_
 
void join(char const *name, std::chrono::milliseconds wait, beast::Journal j)
Returns once all counted in-flight closures are destroyed.
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
beast::Journal debugLog()
Returns a debug journal.