Xclox
C++11 header-only cross-platform date and time library with an asynchronous NTP client
xclox::ntp::QuerySeries Class Reference

QuerySeries is an ephemeral class representing a series of NTP queries. More...

#include <query_series.hpp>

Public Types

Aliases
using Callback = QuerySingle::Callback
 Type of query callback.
 
using DefaultTimeout = internal::DefaultTimeout< QuerySingle, 5000 >
 Type of query timeout milliseconds holder.
 

Public Member Functions

 QuerySeries (asio::io_context &io, const asio::ip::udp::resolver::results_type &endpoints, const std::chrono::milliseconds &timeout)
 Constructs a NTP query series on the given context that targets the given endpoints one at a time until success and runs within the given timeout duration.
 
void cancel ()
 Cancels the query reporting asio::error::operation_aborted to the caller.
 

Static Public Member Functions

static std::weak_ptr< QuerySeriesstart (asio::io_context &io, const asio::ip::udp::resolver::results_type &endpoints, Callback callback, const std::chrono::milliseconds &timeout=std::chrono::milliseconds(DefaultTimeout::ms))
 Starts querying the given endpoints one at a time until success or all endpoints are queried. More...
 

Detailed Description

QuerySeries is an ephemeral class representing a series of NTP queries.

See also
The unit tests in query_series.h for further details.

Member Function Documentation

◆ start()

static std::weak_ptr<QuerySeries> xclox::ntp::QuerySeries::start ( asio::io_context &  io,
const asio::ip::udp::resolver::results_type &  endpoints,
Callback  callback,
const std::chrono::milliseconds &  timeout = std::chrono::milliseconds(DefaultTimeout::ms) 
)
inlinestatic

Starts querying the given endpoints one at a time until success or all endpoints are queried.

Parameters
ioa run context on which the operations of the query are executed.
endpointsa server address list to be queried.
callbacka callable to report the result of the query to the caller.
timeouta time duration after which the query is cancelled if it is not completed.
Returns
a weak reference to the query that helps in tracing it.

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