Bitcoin Core 30.99.0
P2P Digital Currency
Public Member Functions | Public Attributes | List of all members
mp::Waiter Struct Reference

Single element task queue used to handle recursive capnp calls. More...

#include <proxy-io.h>

Collaboration diagram for mp::Waiter:
[legend]

Public Member Functions

 Waiter ()=default
 
template<typename Fn >
void post (Fn &&fn)
 
template<class Predicate >
void wait (Lock &lock, Predicate pred)
 
std::optional< kj::Function< void()> > m_fn MP_GUARDED_BY (m_mutex)
 

Public Attributes

Mutex m_mutex
 Mutex mainly used internally by waiter class, but also used externally to guard access to related state. More...
 
std::condition_variable m_cv
 

Detailed Description

Single element task queue used to handle recursive capnp calls.

(If server makes an callback into the client in the middle of a request, while client thread is blocked waiting for server response, this is what allows the client to run the request in the same thread, the same way code would run in single process, with the callback sharing same thread stack as the original call.

Definition at line 279 of file proxy-io.h.

Constructor & Destructor Documentation

◆ Waiter()

mp::Waiter::Waiter ( )
default

Member Function Documentation

◆ MP_GUARDED_BY()

std::optional< kj::Function< void()> > m_fn mp::Waiter::MP_GUARDED_BY ( m_mutex  )

◆ post()

template<typename Fn >
void mp::Waiter::post ( Fn &&  fn)
inline

Definition at line 284 of file proxy-io.h.

Here is the call graph for this function:

◆ wait()

template<class Predicate >
void mp::Waiter::wait ( Lock lock,
Predicate  pred 
)
inline

Definition at line 293 of file proxy-io.h.

Here is the call graph for this function:

Member Data Documentation

◆ m_cv

std::condition_variable mp::Waiter::m_cv

Definition at line 319 of file proxy-io.h.

◆ m_mutex

Mutex mp::Waiter::m_mutex

Mutex mainly used internally by waiter class, but also used externally to guard access to related state.

Specifically, since the thread_local ThreadContext struct owns a Waiter, the Waiter::m_mutex is used to guard access to other parts of the struct to avoid needing to deal with more mutexes than necessary. This mutex can be held at the same time as EventLoop::m_mutex as long as Waiter::mutex is locked first and EventLoop::m_mutex is locked second.

Definition at line 318 of file proxy-io.h.


The documentation for this struct was generated from the following file: