xrpld
Loading...
Searching...
No Matches
beast::IOLatencyProbe< Clock > Class Template Reference

Measures handler latency on an io_context queue. More...

#include <io_latency_probe.h>

Collaboration diagram for beast::IOLatencyProbe< Clock >:

Classes

struct  SampleOp

Public Member Functions

 IOLatencyProbe (duration const &period, boost::asio::io_context &ios)
 ~IOLatencyProbe ()
template<class Handler>
void sampleOne (Handler &&handler)
 Measure one sample of i/o latency.
template<class Handler>
void sample (Handler &&handler)
 Initiate continuous i/o latency sampling.
boost::asio::io_context & getIoContext ()
 Return the io_context associated with the latency probe.
boost::asio::io_context const & getIoContext () const
void cancel ()
 Cancel all pending i/o.
void cancelAsync ()

Private Types

using duration = Clock::duration
using time_point = Clock::time_point

Private Member Functions

void cancel (std::unique_lock< decltype(mutex_)> &lock, bool wait)
void addref ()
void release ()

Private Attributes

std::recursive_mutex mutex_
std::condition_variable_any cond_
std::size_t count_ {1}
duration const period_
boost::asio::io_context & ios_
boost::asio::basic_waitable_timer< std::chrono::steady_clocktimer_
bool cancel_ {false}

Detailed Description

template<class Clock>
class beast::IOLatencyProbe< Clock >

Measures handler latency on an io_context queue.

Definition at line 18 of file io_latency_probe.h.

Member Typedef Documentation

◆ duration

template<class Clock>
using beast::IOLatencyProbe< Clock >::duration = Clock::duration
private

Definition at line 21 of file io_latency_probe.h.

◆ time_point

template<class Clock>
using beast::IOLatencyProbe< Clock >::time_point = Clock::time_point
private

Definition at line 22 of file io_latency_probe.h.

Constructor & Destructor Documentation

◆ IOLatencyProbe()

template<class Clock>
beast::IOLatencyProbe< Clock >::IOLatencyProbe ( duration const & period,
boost::asio::io_context & ios )

Definition at line 33 of file io_latency_probe.h.

◆ ~IOLatencyProbe()

template<class Clock>
beast::IOLatencyProbe< Clock >::~IOLatencyProbe ( )

Definition at line 38 of file io_latency_probe.h.

Member Function Documentation

◆ getIoContext() [1/2]

template<class Clock>
boost::asio::io_context & beast::IOLatencyProbe< Clock >::getIoContext ( )

Return the io_context associated with the latency probe.

Definition at line 47 of file io_latency_probe.h.

◆ getIoContext() [2/2]

template<class Clock>
boost::asio::io_context const & beast::IOLatencyProbe< Clock >::getIoContext ( ) const
nodiscard

Definition at line 53 of file io_latency_probe.h.

◆ cancel() [1/2]

template<class Clock>
void beast::IOLatencyProbe< Clock >::cancel ( )

Cancel all pending i/o.

Any handlers which have already been queued will still be called.

Definition at line 64 of file io_latency_probe.h.

◆ cancelAsync()

template<class Clock>
void beast::IOLatencyProbe< Clock >::cancelAsync ( )

Definition at line 71 of file io_latency_probe.h.

◆ sampleOne()

template<class Clock>
template<class Handler>
void beast::IOLatencyProbe< Clock >::sampleOne ( Handler && handler)

Measure one sample of i/o latency.

Handler will be called with this signature: void Handler (Duration d);

Definition at line 84 of file io_latency_probe.h.

◆ sample()

template<class Clock>
template<class Handler>
void beast::IOLatencyProbe< Clock >::sample ( Handler && handler)

Initiate continuous i/o latency sampling.

Handler will be called with this signature: void Handler (std::chrono::milliseconds);

Definition at line 99 of file io_latency_probe.h.

◆ cancel() [2/2]

template<class Clock>
void beast::IOLatencyProbe< Clock >::cancel ( std::unique_lock< decltype(mutex_)> & lock,
bool wait )
private

Definition at line 110 of file io_latency_probe.h.

◆ addref()

template<class Clock>
void beast::IOLatencyProbe< Clock >::addref ( )
private

Definition at line 123 of file io_latency_probe.h.

◆ release()

template<class Clock>
void beast::IOLatencyProbe< Clock >::release ( )
private

Definition at line 130 of file io_latency_probe.h.

Member Data Documentation

◆ mutex_

template<class Clock>
std::recursive_mutex beast::IOLatencyProbe< Clock >::mutex_
private

Definition at line 24 of file io_latency_probe.h.

◆ cond_

template<class Clock>
std::condition_variable_any beast::IOLatencyProbe< Clock >::cond_
private

Definition at line 25 of file io_latency_probe.h.

◆ count_

template<class Clock>
std::size_t beast::IOLatencyProbe< Clock >::count_ {1}
private

Definition at line 26 of file io_latency_probe.h.

◆ period_

template<class Clock>
duration const beast::IOLatencyProbe< Clock >::period_
private

Definition at line 27 of file io_latency_probe.h.

◆ ios_

template<class Clock>
boost::asio::io_context& beast::IOLatencyProbe< Clock >::ios_
private

Definition at line 28 of file io_latency_probe.h.

◆ timer_

template<class Clock>
boost::asio::basic_waitable_timer<std::chrono::steady_clock> beast::IOLatencyProbe< Clock >::timer_
private

Definition at line 29 of file io_latency_probe.h.

◆ cancel_

template<class Clock>
bool beast::IOLatencyProbe< Clock >::cancel_ {false}
private

Definition at line 30 of file io_latency_probe.h.