SObjectizer-5 Extra
Loading...
Searching...
No Matches
so_5::extra::sync Namespace Reference

Namespaces

namespace  details
 
namespace  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.
 
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.
 

Enumerations

enum class  close_reply_chain_flag_t { close , 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>
auto request_reply (Target &&target, Duration duration, Args &&...args)
 A helper function for performing request_reply-iteraction.
 
template<typename Request , typename Reply , typename Target , typename Duration , typename... Args>
auto request_opt_reply (Target &&target, Duration duration, Args &&...args)
 A helper function for performing request_reply-iteraction.
 

Variables

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

Typedef Documentation

◆ reply_mhood_t

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

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

Definition at line 1116 of file pub.hpp.

◆ request_mhood_t

template<typename Request , typename Reply >
using so_5::extra::sync::request_mhood_t = 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 1107 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 291 of file pub.hpp.

Function Documentation

◆ request_opt_reply()

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

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:

some_mchain,
10s,
...);
if(r) {
... // Do something with *r.
}
auto request_opt_reply(Target &&target, Duration duration, Args &&...args)
A helper function for performing request_reply-iteraction.
Definition pub.hpp:1182

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

Definition at line 1182 of file pub.hpp.

◆ request_reply()

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

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:

some_mchain,
10s,
...);
auto request_reply(Target &&target, Duration duration, Args &&...args)
A helper function for performing request_reply-iteraction.
Definition pub.hpp:1143

Returns an instance of Reply object.

Definition at line 1143 of file pub.hpp.

Variable Documentation

◆ close_reply_chain

const close_reply_chain_flag_t so_5::extra::sync::close_reply_chain
constexpr
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) {...});
A special class for performing interactions between agents in request-reply maner.
Definition pub.hpp:582
constexpr const close_reply_chain_flag_t close_reply_chain
The indicator that the reply chain should be closed automatically.
Definition pub.hpp:325

Definition at line 325 of file pub.hpp.

◆ do_not_close_reply_chain

const close_reply_chain_flag_t so_5::extra::sync::do_not_close_reply_chain
constexpr
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) {...});
constexpr const close_reply_chain_flag_t do_not_close_reply_chain
The indicator that the reply chain shouldn't be closed automatically.
Definition pub.hpp:358

Definition at line 358 of file pub.hpp.