SObjectizer  5.5
Public Member Functions | Private Attributes | List of all members
so_5::service_invoke_proxy_t< Result > Class Template Reference

A special proxy for service request invocation. More...

#include <mbox.hpp>

Public Member Functions

 service_invoke_proxy_t (const mbox_t &mbox)
 
 service_invoke_proxy_t (mbox_t &&mbox)
 
template<class Param >
std::future< Result > async () const
 Make asynchronous service request. More...
 
template<class Request_Type , class Envelope_Type >
std::future< Result > async_2 (intrusive_ptr_t< Envelope_Type > msg_ref) const
 Make service request call with param. More...
 
template<class Request_Type >
std::future< Result > async (intrusive_ptr_t< Request_Type > msg_ref) const
 Make service request call with param. More...
 
template<class Param >
std::future< Result > async (std::unique_ptr< Param > msg_unique_ptr) const
 Make service request call with param. More...
 
template<class Param >
std::future< Result > async (Param *msg) const
 Make service request call with param. More...
 
infinite_wait_service_invoke_proxy_t< Result > wait_forever () const
 
infinite_wait_service_invoke_proxy_t< Result > get_wait_proxy (infinite_wait_indication) const
 A helper method for create a proxy for infinite waiting on service request. More...
 
template<class Duration >
wait_for_service_invoke_proxy_t< Result, Duration > wait_for (const Duration &timeout) const
 
template<class Duration >
wait_for_service_invoke_proxy_t< Result, Duration > get_wait_proxy (const Duration &timeout) const
 A helper method to create a proxy for waiting on service request for a timeout. More...
 
template<class Param , typename... Args>
std::future< Result > make_async (Args &&... args) const
 Create param and make service request call. More...
 

Private Attributes

mbox_t m_mbox
 

Detailed Description

template<class Result>
class so_5::service_invoke_proxy_t< Result >

A special proxy for service request invocation.

Since
v.5.3.0

Constructor & Destructor Documentation

◆ service_invoke_proxy_t() [1/2]

template<class Result >
so_5::service_invoke_proxy_t< Result >::service_invoke_proxy_t ( const mbox_t mbox)
explicit

◆ service_invoke_proxy_t() [2/2]

template<class Result >
so_5::service_invoke_proxy_t< Result >::service_invoke_proxy_t ( mbox_t &&  mbox)
explicit

Member Function Documentation

◆ async() [1/4]

template<class Result >
template<class Param >
std::future< Result > so_5::service_invoke_proxy_t< Result >::async ( ) const

Make asynchronous service request.

This method should be used for the cases where Param is a signal.

Template Parameters
Paramtype of signal to be sent to distination.
Usage example:
const so_5::mbox_t & dest = ...;
std::future< std::string > result = dest.get_one< std::string >().async< status_signal >();

◆ async() [2/4]

template<class Result >
template<class Request_Type >
std::future< Result > so_5::service_invoke_proxy_t< Result >::async ( intrusive_ptr_t< Request_Type >  msg_ref) const

Make service request call with param.

This method should be used for the case where Param is a message.

Template Parameters
Request_Typetype of message to be sent to distination.
Usage example:
void some_agent::some_event( mhood_t< request > req )
{
const so_5::mbox_t & dest = ...;
std::future< std::string > result = dest.get_one< std::string >().async( req.make_reference() );
}

◆ async() [3/4]

template<class Result >
template<class Param >
std::future< Result > so_5::service_invoke_proxy_t< Result >::async ( std::unique_ptr< Param >  msg_unique_ptr) const

Make service request call with param.

This method should be used for the case where Param is a message.

Template Parameters
Paramtype of message to be sent to distination.
Usage example:
const so_5::mbox_t & dest = ...;
std::future< std::string > result = dest.get_one< std::string >().async( std::make_unique< request >(...) );

◆ async() [4/4]

template<class Result >
template<class Param >
std::future< Result > so_5::service_invoke_proxy_t< Result >::async ( Param *  msg) const

Make service request call with param.

This method should be used for the case where Param is a message.

Template Parameters
Paramtype of message to be sent to distination.
Usage example:
const so_5::mbox_t & dest = ...;
std::future< std::string > result = dest.get_one< std::string >().async( new request(...) );

◆ async_2()

template<class Result >
template<class Request_Type , class Envelope_Type >
std::future< Result > so_5::service_invoke_proxy_t< Result >::async_2 ( intrusive_ptr_t< Envelope_Type >  msg_ref) const

Make service request call with param.

This method should be used for the case where Envelope_Type is a message.

Note
This method was added in v.5.5.19 for suppor immutable_msg<T> and mutable_msg<T> message objects.
Attention
This method is not a part of stable SObjectizer's API. Don't use it in your code because it is a subject of changes in the future version of SObjectizer. Use so_5::request_value() or so_5::request_future() instead.
Template Parameters
Request_Typetype to which receiver must be subscribed.
Envelope_Typetype of message object to be sent.
Since
v.5.5.19

◆ get_wait_proxy() [1/2]

template<class Result >
infinite_wait_service_invoke_proxy_t< Result > so_5::service_invoke_proxy_t< Result >::get_wait_proxy ( infinite_wait_indication  ) const
inline

A helper method for create a proxy for infinite waiting on service request.

Since
v.5.5.9

◆ get_wait_proxy() [2/2]

template<class Result >
template<class Duration >
wait_for_service_invoke_proxy_t< Result, Duration > so_5::service_invoke_proxy_t< Result >::get_wait_proxy ( const Duration &  timeout) const
inline

A helper method to create a proxy for waiting on service request for a timeout.

Since
v.5.5.9
Parameters
timeoutTimeout for std::future::wait_for().

◆ make_async()

template<class Result >
template<class Param , typename... Args>
std::future< Result > so_5::service_invoke_proxy_t< Result >::make_async ( Args &&...  args) const

Create param and make service request call.

This method should be used for the case where Param is a message.

Template Parameters
Paramtype of message to be sent to distination.
Argstypes of Param's constructor arguments.
Usage example:
const so_5::mbox_t & dest = ...;
std::future< std::string > result = dest.get_one< std::string >().make_async< request >(...) );

◆ wait_for()

template<class Result >
template<class Duration >
wait_for_service_invoke_proxy_t< Result, Duration > so_5::service_invoke_proxy_t< Result >::wait_for ( const Duration &  timeout) const

Make another proxy for time-limited synchronous service requests calls.

This method is used as second part of method chain for synchronous interaction. It must be used if service request initiator want to wait response no more than specified amount of time.

The call to wait_for if equivalent of:

std::future< Resp > f = mbox.get_one< Resp >().make_async< Req >(...);
auto wait_result = f.wait_for( timeout );
if( std::future_status::ready != wait_result )
throw some_exception();
Resp r = f.get();

It means that return conditions for wait_for() are the same as return conditions for underlying call to std::future::wait_for().

Usage example:
const so_5::mbox_t & dest = ...;
std::string r = dest.get_one< std::string >().wait_for(std::chrono::milliseconds(50)).make_sync_get< request >(...);
Parameters
timeoutTimeout for std::future::wait_for().

◆ wait_forever()

template<class Result >
infinite_wait_service_invoke_proxy_t< Result > so_5::service_invoke_proxy_t< Result >::wait_forever ( ) const

Make another proxy for time-unlimited synchronous service request calls.

This method is used as second part of method chain for synchronous interaction. It must be used if service request initiator want to wait response of infinite amount of time.

The call to wait_forever if equivalent of:

std::future< Resp > f = mbox.get_one< Resp >().make_async< Req >(...);
Resp r = f.get();

It means that return conditions for wait_forever() are the same as return conditions for underlying call to std::future::get().

Usage example:
const so_5::mbox_t & dest = ...;
std::string r = dest.get_one< std::string >().wait_forever().make_sync_get< request >(...);

Member Data Documentation

◆ m_mbox

template<class Result >
mbox_t so_5::service_invoke_proxy_t< Result >::m_mbox
private

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