asio-grpc v3.1.0
Asynchronous gRPC with Asio/unified executors
agrpc::BasicGrpcExecutor< Allocator, Options > Class Template Reference

GrpcContext's executor. More...

#include <agrpc/grpc_executor.hpp>

Inherits detail::ConditionalT< detail::is_outstanding_work_tracked(Options), detail::GrpcExecutorWorkTrackerBase< Allocator >, detail::GrpcExecutorBase< Allocator > >.

Public Types

using allocator_type = Allocator
 The associated allocator type.
 

Public Member Functions

 BasicGrpcExecutor ()=default
 Default construct an executor. More...
 
constexpr agrpc::GrpcContextcontext () const noexcept
 Get the underlying GrpcContext. More...
 
constexpr allocator_type get_allocator () const noexcept
 Get the associated allocator. More...
 
bool running_in_this_thread () const noexcept
 Determine whether the GrpcContext is running in the current thread. More...
 
void on_work_started () const noexcept
 Signal the GrpcContext that an asynchronous operation is in progress. More...
 
void on_work_finished () const noexcept
 Signal the GrpcContext that an asynchronous operation has completed. More...
 
template<class Function , class OtherAllocator >
void dispatch (Function &&function, const OtherAllocator &other_allocator) const
 Request the GrpcContext to invoke the given function object. More...
 
template<class Function , class OtherAllocator >
void post (Function &&function, const OtherAllocator &other_allocator) const
 Request the GrpcContext to invoke the given function object. More...
 
template<class Function , class OtherAllocator >
void defer (Function &&function, const OtherAllocator &other_allocator) const
 Request the GrpcContext to invoke the given function object. More...
 
template<class Function >
void execute (Function &&function) const
 Request the GrpcContext to invoke the given function object. More...
 
detail::ScheduleSender schedule () const noexcept
 Create a Sender that completes on the GrpcContext. More...
 
constexpr auto require (asio::execution::blocking_t::possibly_t) const noexcept -> agrpc::BasicGrpcExecutor< Allocator, detail::set_blocking_never(Options, false)>
 Obtain an executor with the blocking.possibly property. More...
 
constexpr auto require (asio::execution::blocking_t::never_t) const noexcept -> agrpc::BasicGrpcExecutor< Allocator, detail::set_blocking_never(Options, true)>
 Obtain an executor with the blocking.never property. More...
 
constexpr auto prefer (asio::execution::relationship_t::fork_t) const noexcept
 Obtain an executor with the relationship.fork property. More...
 
constexpr auto prefer (asio::execution::relationship_t::continuation_t) const noexcept
 Obtain an executor with the relationship.continuation property. More...
 
constexpr auto require (asio::execution::outstanding_work_t::tracked_t) const noexcept -> agrpc::BasicGrpcExecutor< Allocator, detail::set_outstanding_work_tracked(Options, true)>
 Obtain an executor with the outstanding_work.tracked property. More...
 
constexpr auto require (asio::execution::outstanding_work_t::untracked_t) const noexcept -> agrpc::BasicGrpcExecutor< Allocator, detail::set_outstanding_work_tracked(Options, false)>
 Obtain an executor with the outstanding_work.untracked property. More...
 
template<class OtherAllocator >
constexpr auto require (asio::execution::allocator_t< OtherAllocator > other_allocator) const noexcept -> agrpc::BasicGrpcExecutor< OtherAllocator, Options >
 Obtain an executor with the specified allocator property. More...
 
constexpr auto require (asio::execution::allocator_t< void >) const noexcept -> agrpc::BasicGrpcExecutor< std::allocator< void >, Options >
 Obtain an executor with the default allocator property. More...
 
constexpr agrpc::GrpcContextquery (asio::execution::context_t) const noexcept
 Query the current value of the context property. More...
 
template<class OtherAllocator >
constexpr allocator_type query (asio::execution::allocator_t< OtherAllocator >) const noexcept
 Query the current value of the allocator property. More...
 

Static Public Member Functions

static constexpr auto query (asio::execution::blocking_t) noexcept
 Query the current value of the blocking property. More...
 
static constexpr detail::QueryStaticMapping::result_type query (asio::execution::mapping_t) noexcept
 Query the current value of the mapping property. More...
 
static constexpr detail::QueryStaticRelationship::result_type query (asio::execution::relationship_t) noexcept
 Query the current value of the relationship property. More...
 
static constexpr auto query (asio::execution::outstanding_work_t) noexcept
 Query the current value of the outstanding_work property. More...
 

Friends

template<std::uint32_t OtherOptions>
constexpr bool operator== (const BasicGrpcExecutor &lhs, const agrpc::BasicGrpcExecutor< Allocator, OtherOptions > &rhs) noexcept
 Compare two GrpcExecutor for equality. More...
 
template<std::uint32_t OtherOptions>
constexpr bool operator!= (const BasicGrpcExecutor &lhs, const agrpc::BasicGrpcExecutor< Allocator, OtherOptions > &rhs) noexcept
 Compare two GrpcExecutor for inequality. More...
 

Detailed Description

template<class Allocator, std::uint32_t Options>
class agrpc::BasicGrpcExecutor< Allocator, Options >

GrpcContext's executor.

A lightweight handle to a GrpcContext. Trivially copyable if it is not tracking outstanding work.

Satisfies the Executor and Networking TS and Scheduler requirements and can therefore be used in places where Asio/libunifex expects an Executor or Scheduler.

Constructor & Destructor Documentation

◆ BasicGrpcExecutor()

template<class Allocator , std::uint32_t Options>
agrpc::BasicGrpcExecutor< Allocator, Options >::BasicGrpcExecutor ( )
default

Default construct an executor.

The constructed object may not be used until it is assigned a valid executor, for example through GrpcContext::get_executor.

Member Function Documentation

◆ context()

template<class Allocator , std::uint32_t Options>
constexpr agrpc::GrpcContext & agrpc::BasicGrpcExecutor< Allocator, Options >::context ( ) const
inlineconstexprnoexcept

Get the underlying GrpcContext.

Thread-safe

Since 1.6.0 this function is hidden when (BOOST_)ASIO_NO_TS_EXECUTORS is defined.

◆ get_allocator()

template<class Allocator , std::uint32_t Options>
constexpr allocator_type agrpc::BasicGrpcExecutor< Allocator, Options >::get_allocator ( ) const
inlineconstexprnoexcept

Get the associated allocator.

Thread-safe

◆ running_in_this_thread()

template<class Allocator , std::uint32_t Options>
bool agrpc::BasicGrpcExecutor< Allocator, Options >::running_in_this_thread ( ) const
inlinenoexcept

Determine whether the GrpcContext is running in the current thread.

Thread-safe

◆ on_work_started()

template<class Allocator , std::uint32_t Options>
void agrpc::BasicGrpcExecutor< Allocator, Options >::on_work_started ( ) const
inlinenoexcept

Signal the GrpcContext that an asynchronous operation is in progress.

Thread-safe

Since 1.6.0 this function is hidden when (BOOST_)ASIO_NO_TS_EXECUTORS is defined.

◆ on_work_finished()

template<class Allocator , std::uint32_t Options>
void agrpc::BasicGrpcExecutor< Allocator, Options >::on_work_finished ( ) const
inlinenoexcept

Signal the GrpcContext that an asynchronous operation has completed.

Once all outstanding asynchronous operations have completed the GrpcContext will go into the stopped state.

Thread-safe

Since 1.6.0 this function is hidden when (BOOST_)ASIO_NO_TS_EXECUTORS is defined.

◆ dispatch()

template<class Allocator , std::uint32_t Options>
template<class Function , class OtherAllocator >
void agrpc::BasicGrpcExecutor< Allocator, Options >::dispatch ( Function &&  function,
const OtherAllocator &  other_allocator 
) const
inline

Request the GrpcContext to invoke the given function object.

Do not call this function directly, it is intended to be used by the asio::dispatch free function.

Thread-safe

Since 1.6.0 this function is hidden when (BOOST_)ASIO_NO_TS_EXECUTORS is defined.

◆ post()

template<class Allocator , std::uint32_t Options>
template<class Function , class OtherAllocator >
void agrpc::BasicGrpcExecutor< Allocator, Options >::post ( Function &&  function,
const OtherAllocator &  other_allocator 
) const
inline

Request the GrpcContext to invoke the given function object.

Do not call this function directly, it is intended to be used by the asio::post free function.

Thread-safe

Since 1.6.0 this function is hidden when (BOOST_)ASIO_NO_TS_EXECUTORS is defined.

◆ defer()

template<class Allocator , std::uint32_t Options>
template<class Function , class OtherAllocator >
void agrpc::BasicGrpcExecutor< Allocator, Options >::defer ( Function &&  function,
const OtherAllocator &  other_allocator 
) const
inline

Request the GrpcContext to invoke the given function object.

Do not call this function directly, it is intended to be used by the asio::defer free function.

Thread-safe

Since 1.6.0 this function is hidden when (BOOST_)ASIO_NO_TS_EXECUTORS is defined.

◆ execute()

template<class Allocator , std::uint32_t Options>
template<class Function >
void agrpc::BasicGrpcExecutor< Allocator, Options >::execute ( Function &&  function) const
inline

Request the GrpcContext to invoke the given function object.

Do not call this function directly. It is intended to be used by the asio::execution::execute customisation point.

Thread-safe

◆ schedule()

template<class Allocator , std::uint32_t Options>
detail::ScheduleSender agrpc::BasicGrpcExecutor< Allocator, Options >::schedule ( ) const
inlinenoexcept

Create a Sender that completes on the GrpcContext.

Do not call this function directly. It is intended to be used by the asio::execution::schedule customisation point.

Thread-safe

◆ require() [1/6]

template<class Allocator , std::uint32_t Options>
constexpr auto agrpc::BasicGrpcExecutor< Allocator, Options >::require ( asio::execution::blocking_t::possibly_t  ) const -> agrpc::BasicGrpcExecutor<Allocator, detail::set_blocking_never(Options, false)>
inlineconstexprnoexcept

Obtain an executor with the blocking.possibly property.

Do not call this function directly. It is intended to be used by the asio::require customisation point.

Thread-safe

◆ require() [2/6]

template<class Allocator , std::uint32_t Options>
constexpr auto agrpc::BasicGrpcExecutor< Allocator, Options >::require ( asio::execution::blocking_t::never_t  ) const -> agrpc::BasicGrpcExecutor<Allocator, detail::set_blocking_never(Options, true)>
inlineconstexprnoexcept

Obtain an executor with the blocking.never property.

Do not call this function directly. It is intended to be used by the asio::require customisation point.

Thread-safe

◆ prefer() [1/2]

template<class Allocator , std::uint32_t Options>
constexpr auto agrpc::BasicGrpcExecutor< Allocator, Options >::prefer ( asio::execution::relationship_t::fork_t  ) const
inlineconstexprnoexcept

Obtain an executor with the relationship.fork property.

The GrpcExecutor always forks.

Do not call this function directly. It is intended to be used by the asio::prefer customisation point.

Thread-safe

◆ prefer() [2/2]

template<class Allocator , std::uint32_t Options>
constexpr auto agrpc::BasicGrpcExecutor< Allocator, Options >::prefer ( asio::execution::relationship_t::continuation_t  ) const
inlineconstexprnoexcept

Obtain an executor with the relationship.continuation property.

The GrpcExecutor does not support continuation.

Do not call this function directly. It is intended to be used by the asio::prefer customisation point.

Thread-safe

◆ require() [3/6]

template<class Allocator , std::uint32_t Options>
constexpr auto agrpc::BasicGrpcExecutor< Allocator, Options >::require ( asio::execution::outstanding_work_t::tracked_t  ) const -> agrpc::BasicGrpcExecutor<Allocator, detail::set_outstanding_work_tracked(Options, true)>
inlineconstexprnoexcept

Obtain an executor with the outstanding_work.tracked property.

Do not call this function directly. It is intended to be used by the asio::require customisation point.

Thread-safe

◆ require() [4/6]

template<class Allocator , std::uint32_t Options>
constexpr auto agrpc::BasicGrpcExecutor< Allocator, Options >::require ( asio::execution::outstanding_work_t::untracked_t  ) const -> agrpc::BasicGrpcExecutor<Allocator, detail::set_outstanding_work_tracked(Options, false)>
inlineconstexprnoexcept

Obtain an executor with the outstanding_work.untracked property.

Do not call this function directly. It is intended to be used by the asio::require customisation point.

Thread-safe

◆ require() [5/6]

template<class Allocator , std::uint32_t Options>
template<class OtherAllocator >
constexpr auto agrpc::BasicGrpcExecutor< Allocator, Options >::require ( asio::execution::allocator_t< OtherAllocator >  other_allocator) const -> agrpc::BasicGrpcExecutor<OtherAllocator, Options>
inlineconstexprnoexcept

Obtain an executor with the specified allocator property.

Do not call this function directly. It is intended to be used by the asio::require customisation point.

Thread-safe

◆ require() [6/6]

template<class Allocator , std::uint32_t Options>
constexpr auto agrpc::BasicGrpcExecutor< Allocator, Options >::require ( asio::execution::allocator_t< void >  ) const -> agrpc::BasicGrpcExecutor<std::allocator<void>, Options>
inlineconstexprnoexcept

Obtain an executor with the default allocator property.

Do not call this function directly. It is intended to be used by the asio::require customisation point.

Thread-safe

◆ query() [1/6]

template<class Allocator , std::uint32_t Options>
static constexpr auto agrpc::BasicGrpcExecutor< Allocator, Options >::query ( asio::execution::blocking_t  )
inlinestaticconstexprnoexcept

Query the current value of the blocking property.

Do not call this function directly. It is intended to be used by the asio::query customisation point.

Thread-safe

◆ query() [2/6]

template<class Allocator , std::uint32_t Options>
static constexpr detail::QueryStaticMapping::result_type agrpc::BasicGrpcExecutor< Allocator, Options >::query ( asio::execution::mapping_t  )
inlinestaticconstexprnoexcept

Query the current value of the mapping property.

Do not call this function directly. It is intended to be used by the asio::query customisation point.

Thread-safe

◆ query() [3/6]

template<class Allocator , std::uint32_t Options>
constexpr agrpc::GrpcContext & agrpc::BasicGrpcExecutor< Allocator, Options >::query ( asio::execution::context_t  ) const
inlineconstexprnoexcept

Query the current value of the context property.

Do not call this function directly. It is intended to be used by the asio::query customisation point.

Thread-safe

◆ query() [4/6]

template<class Allocator , std::uint32_t Options>
static constexpr detail::QueryStaticRelationship::result_type agrpc::BasicGrpcExecutor< Allocator, Options >::query ( asio::execution::relationship_t  )
inlinestaticconstexprnoexcept

Query the current value of the relationship property.

Do not call this function directly. It is intended to be used by the asio::query customisation point.

Thread-safe

◆ query() [5/6]

template<class Allocator , std::uint32_t Options>
static constexpr auto agrpc::BasicGrpcExecutor< Allocator, Options >::query ( asio::execution::outstanding_work_t  )
inlinestaticconstexprnoexcept

Query the current value of the outstanding_work property.

Do not call this function directly. It is intended to be used by the asio::query customisation point.

Thread-safe

◆ query() [6/6]

template<class Allocator , std::uint32_t Options>
template<class OtherAllocator >
constexpr allocator_type agrpc::BasicGrpcExecutor< Allocator, Options >::query ( asio::execution::allocator_t< OtherAllocator >  ) const
inlineconstexprnoexcept

Query the current value of the allocator property.

Do not call this function directly. It is intended to be used by the asio::query customisation point.

Thread-safe

Friends And Related Function Documentation

◆ operator==

template<class Allocator , std::uint32_t Options>
template<std::uint32_t OtherOptions>
constexpr bool operator== ( const BasicGrpcExecutor< Allocator, Options > &  lhs,
const agrpc::BasicGrpcExecutor< Allocator, OtherOptions > &  rhs 
)
friend

Compare two GrpcExecutor for equality.

Returns true if the two executors can be interchanged with identical effects.

Thread-safe

◆ operator!=

template<class Allocator , std::uint32_t Options>
template<std::uint32_t OtherOptions>
constexpr bool operator!= ( const BasicGrpcExecutor< Allocator, Options > &  lhs,
const agrpc::BasicGrpcExecutor< Allocator, OtherOptions > &  rhs 
)
friend

Compare two GrpcExecutor for inequality.

Returns true if interchanging the two executors may not lead to identical effects.

Thread-safe