SObjectizer-5 Extra
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
so_5::extra::sync Namespace Reference

Namespaces

 details
 
 errors
 

Classes

class  request_reply_t
 A special class for performing interactions between agents in request-reply maner. More...
 

Typedefs

template<typename Request , typename Reply >
using request_mhood_t = typename request_reply_t< Request, Reply >::request_mhood_t
 A short form of request_reply_t<Q,A>::request_mhood_t. More...
 
template<typename Request , typename Reply >
using reply_mhood_t = typename request_reply_t< Request, Reply >::reply_mhood_t
 A short form of request_reply_t<Q,A>::reply_mhood_t. More...
 

Enumerations

enum  close_reply_chain_flag_t { close_reply_chain_flag_t::close, close_reply_chain_flag_t::do_not_close }
 A flag to specify should the reply chain be closed automatically. More...
 

Functions

template<typename Request , typename Reply , typename Target , typename Duration , typename... Args>
SO_5_NODISCARD auto request_reply (Target &&target, Duration duration, Args &&...args)
 A helper function for performing request_reply-iteraction. More...
 
template<typename Request , typename Reply , typename Target , typename Duration , typename... Args>
SO_5_NODISCARD auto request_opt_reply (Target &&target, Duration duration, Args &&...args)
 A helper function for performing request_reply-iteraction. More...
 

Variables

constexpr const close_reply_chain_flag_t close_reply_chain
 The indicator that the reply chain should be closed automatically. More...
 
constexpr const close_reply_chain_flag_t do_not_close_reply_chain
 The indicator that the reply chain shouldn't be closed automatically. More...
 

Typedef Documentation

◆ reply_mhood_t

template<typename Request , typename Reply >
using so_5::extra::sync::reply_mhood_t = typedef typename request_reply_t<Request, Reply>::reply_mhood_t

A short form of request_reply_t<Q,A>::reply_mhood_t.

Definition at line 1104 of file pub.hpp.

◆ request_mhood_t

template<typename Request , typename Reply >
using so_5::extra::sync::request_mhood_t = typedef typename request_reply_t<Request, Reply>::request_mhood_t

A short form of request_reply_t<Q,A>::request_mhood_t.

Usage example:

namespace sync_ns = so_5::extra::sync;
class service final : public so_5::agent_t {
...
void on_request(sync_ns::request_mhood_t<my_request, my_reply> cmd) {
...
cmd->make_reply(...);
}
};

Definition at line 1095 of file pub.hpp.

Enumeration Type Documentation

◆ close_reply_chain_flag_t

A flag to specify should the reply chain be closed automatically.

Enumerator
close 

The reply chain should be automatically closed when the corresponding request_reply_t instance is being destroyed.

do_not_close 

The reply chain shouldn't be closed even if the corresponding request_reply_t instance is destroyed. A user should close the reply chain manually.

Definition at line 281 of file pub.hpp.

Function Documentation

◆ request_opt_reply()

template<typename Request , typename Reply , typename Target , typename Duration , typename... Args>
SO_5_NODISCARD auto so_5::extra::sync::request_opt_reply ( Target &&  target,
Duration  duration,
Args &&...  args 
)

A helper function for performing request_reply-iteraction.

Sends a so_5::extra::sync::request_reply_t <Request,Reply> to the specified target and waits the reply for no more that duration. If there is no reply then an empty optional object will be returned.

Usage example:

auto r = so_5::extra::sync::request_opt_reply<my_request, my_reply>(
some_mchain,
10s,
...);
if(r) {
... // Do something with *r.
}

Returns an instance of std::optional<Reply> object.

Definition at line 1170 of file pub.hpp.

◆ request_reply()

template<typename Request , typename Reply , typename Target , typename Duration , typename... Args>
SO_5_NODISCARD auto so_5::extra::sync::request_reply ( Target &&  target,
Duration  duration,
Args &&...  args 
)

A helper function for performing request_reply-iteraction.

Sends a so_5::extra::sync::request_reply_t <Request,Reply> to the specified target and waits the reply for no more that duration. If there is no reply then an exception will be thrown.

Usage example:

auto r = so_5::extra::sync::request_reply<my_request, my_reply>(
some_mchain,
10s,
...);

Returns an instance of Reply object.

Definition at line 1131 of file pub.hpp.

Variable Documentation

◆ close_reply_chain

constexpr const close_reply_chain_flag_t so_5::extra::sync::close_reply_chain
Initial value:
=
close_reply_chain_flag_t::close

The indicator that the reply chain should be closed automatically.

If this flag is used then the reply chain will be automatically closed when the corresponding request_reply_t instance is being destroyed.

Usage example:

// Create the reply chain manually.
auto reply_ch = create_mchain(env);
// Issue a request.
my_ask_reply::initiate_with_custom_reply_to(
target,
reply_ch,
...);
... // Do something.
// Now we can read the reply.
// The reply chain will be automatically closed after dispatching of the request.
receive(from(reply_ch).handle_n(1),
[](typename my_ask_reply::reply_mhood_t cmd) {...});

Definition at line 315 of file pub.hpp.

◆ do_not_close_reply_chain

constexpr const close_reply_chain_flag_t so_5::extra::sync::do_not_close_reply_chain
Initial value:
=
close_reply_chain_flag_t::do_not_close

The indicator that the reply chain shouldn't be closed automatically.

If this flag is used then the reply chain won't be automatically closed when the corresponding request_reply_t instance is being destroyed. It means that one reply chain can be used for receiving of different replies:

// Create the reply chain manually.
auto reply_ch = create_mchain(env);
// Issue the first request.
one_ask_reply::initiate_with_custom_reply_to(
one_target,
reply_ch,
...);
// Issue the second request.
another_ask_reply::initiate_with_custom_reply_to(
another_target,
reply_ch,
...);
... // Do something.
// Now we can read the replies.
receive(from(reply_ch).handle_n(2),
[](typename one_ask_reply::reply_mhood_t cmd) {...},
[](typename another_ask_reply::reply_mhood_t cmd) {...});

Definition at line 348 of file pub.hpp.