asio-grpc v3.3.0
Asynchronous gRPC with Asio/unified executors
Loading...
Searching...
No Matches
agrpc::BasicGrpcExecutor< Allocator, Options > Class Template Reference

GrpcContext's executor. More...

#include <agrpc/grpc_executor.hpp>

Public Types

using allocator_type = Allocator
 The associated allocator type.
 

Public Member Functions

 BasicGrpcExecutor ()=default
 Default construct an executor.
 
constexpr agrpc::GrpcContextcontext () const noexcept
 Get the underlying GrpcContext.
 
constexpr allocator_type get_allocator () const noexcept
 Get the associated allocator.
 
bool running_in_this_thread () const noexcept
 Determine whether the GrpcContext is running in the current thread.
 
void on_work_started () const noexcept
 Signal the GrpcContext that an asynchronous operation is in progress.
 
void on_work_finished () const noexcept
 Signal the GrpcContext that an asynchronous operation has completed.
 
template<class Function , class OtherAllocator >
void dispatch (Function &&function, const OtherAllocator &other_allocator) const
 Request the GrpcContext to invoke the given function object.
 
template<class Function , class OtherAllocator >
void post (Function &&function, const OtherAllocator &other_allocator) const
 Request the GrpcContext to invoke the given function object.
 
template<class Function , class OtherAllocator >
void defer (Function &&function, const OtherAllocator &other_allocator) const
 Request the GrpcContext to invoke the given function object.
 
template<class Function >
void execute (Function &&function) const
 Request the GrpcContext to invoke the given function object.
 
detail::ScheduleSender schedule () const noexcept
 Create a Sender that completes on the GrpcContext.
 
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.
 
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.
 
constexpr auto prefer (asio::execution::relationship_t::fork_t) const noexcept
 Obtain an executor with the relationship.fork property.
 
constexpr auto prefer (asio::execution::relationship_t::continuation_t) const noexcept
 Obtain an executor with the relationship.continuation property.
 
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.
 
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.
 
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.
 
constexpr auto require (asio::execution::allocator_t< void >) const noexcept -> agrpc::BasicGrpcExecutor< std::allocator< void >, Options >
 Obtain an executor with the default allocator property.
 
constexpr agrpc::GrpcContextquery (asio::execution::context_t) const noexcept
 Query the current value of the context property.
 
template<class OtherAllocator >
constexpr allocator_type query (asio::execution::allocator_t< OtherAllocator >) const noexcept
 Query the current value of the allocator property.
 

Static Public Member Functions

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

Friends

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

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>
agrpc::GrpcContext & agrpc::BasicGrpcExecutor< Allocator, Options >::context ( ) const
inlinenodiscardconstexprnoexcept

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>
allocator_type agrpc::BasicGrpcExecutor< Allocator, Options >::get_allocator ( ) const
inlinenodiscardconstexprnoexcept

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
inlinenodiscardnoexcept

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.

Thread-safe

◆ schedule()

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

Create a Sender that completes on the GrpcContext.

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

Thread-safe

◆ require() [1/6]

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

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>
auto agrpc::BasicGrpcExecutor< Allocator, Options >::require ( asio::execution::blocking_t::never_t ) const -> agrpc::BasicGrpcExecutor<Allocator, detail::set_blocking_never(Options, true)>
inlinenodiscardconstexprnoexcept

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>
auto agrpc::BasicGrpcExecutor< Allocator, Options >::prefer ( asio::execution::relationship_t::fork_t ) const
inlinenodiscardconstexprnoexcept

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>
auto agrpc::BasicGrpcExecutor< Allocator, Options >::prefer ( asio::execution::relationship_t::continuation_t ) const
inlinenodiscardconstexprnoexcept

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>
auto agrpc::BasicGrpcExecutor< Allocator, Options >::require ( asio::execution::outstanding_work_t::tracked_t ) const -> agrpc::BasicGrpcExecutor<Allocator, detail::set_outstanding_work_tracked(Options, true)>
inlinenodiscardconstexprnoexcept

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>
auto agrpc::BasicGrpcExecutor< Allocator, Options >::require ( asio::execution::outstanding_work_t::untracked_t ) const -> agrpc::BasicGrpcExecutor<Allocator, detail::set_outstanding_work_tracked(Options, false)>
inlinenodiscardconstexprnoexcept

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 >
auto agrpc::BasicGrpcExecutor< Allocator, Options >::require ( asio::execution::allocator_t< OtherAllocator > other_allocator) const -> agrpc::BasicGrpcExecutor<OtherAllocator, Options>
inlinenodiscardconstexprnoexcept

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>
auto agrpc::BasicGrpcExecutor< Allocator, Options >::require ( asio::execution::allocator_t< void > ) const -> agrpc::BasicGrpcExecutor<std::allocator<void>, Options>
inlinenodiscardconstexprnoexcept

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 )
inlinestaticnodiscardconstexprnoexcept

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 )
inlinestaticnodiscardconstexprnoexcept

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>
agrpc::GrpcContext & agrpc::BasicGrpcExecutor< Allocator, Options >::query ( asio::execution::context_t ) const
inlinenodiscardconstexprnoexcept

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 )
inlinestaticnodiscardconstexprnoexcept

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 )
inlinestaticnodiscardconstexprnoexcept

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 >
allocator_type agrpc::BasicGrpcExecutor< Allocator, Options >::query ( asio::execution::allocator_t< OtherAllocator > ) const
inlinenodiscardconstexprnoexcept

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 Symbol Documentation

◆ operator==

template<class Allocator , std::uint32_t Options>
template<std::uint32_t OtherOptions>
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>
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