SObjectizer-5 Extra
Namespaces | Classes | Typedefs | Enumerations | Functions
so_5::extra::mboxes::retained_msg Namespace Reference

Namespaces

 details
 
 errors
 

Classes

struct  no_service_request_traits_t
 Traits for the case when service requests are not supported. More...
 
struct  with_service_request_traits_t
 Traits for the case when service requests are supported. More...
 

Typedefs

using default_traits_t = no_service_request_traits_t
 Default traits for retained message mbox. More...
 

Enumerations

enum  service_request_support_t { service_request_support_t::disabled, service_request_support_t::enabled }
 Indiction of service requests support for retained message mbox. More...
 

Functions

template<typename Traits = default_traits_t, typename Lock_Type = std::mutex>
mbox_t make_mbox (environment_t &env)
 Create an instance of retained message mbox. More...
 

Typedef Documentation

◆ default_traits_t

Default traits for retained message mbox.

Definition at line 934 of file retained_msg.hpp.

Enumeration Type Documentation

◆ service_request_support_t

Indiction of service requests support for retained message mbox.

Since
v.1.0.3
Enumerator
disabled 

Service requests are not supported. This the default value for retained message mboxes.

enabled 

Service requests are supported.

Definition at line 54 of file retained_msg.hpp.

Function Documentation

◆ make_mbox()

template<typename Traits = default_traits_t, typename Lock_Type = std::mutex>
mbox_t so_5::extra::mboxes::retained_msg::make_mbox ( environment_t &  env)

Create an instance of retained message mbox.

Simple usage example:

so_5::environment_t & env = ...;
const so_5::mbox_t retained_mbox = so_5::extra::mboxes::retained_msg::make_mbox<>(env);
so_5::send<Some_Message>(retained_mbox, ...);

An instance of default implementation retained message mbox will be created. This instance will be protected by std::mutex.

If you want to use retained_mbox in a single-threaded environment without a multithreaded protection then so_5::null_mutex_t (or any similar null-mutex implementation) can be used:

so_5::environment_t & env = ...
const so_5::mbox_t retained_mbox =
so_5::null_mutex_t>(env);
so_5::send<Some_Message>(retained_mbox, ...);

If you want to use your own mutex-like object (with interface which allows to use your mutex-like class with std::lock_guard) then you can do it similar way:

so_5::environment_t & env = ...
const so_5::mbox_t retained_mbox =
Your_Own_Mutex_Class>(env);
so_5::send<Some_Message>(retained_mbox, ...);

By default service requests are not supported on retained message mboxes. It means that attempt to call so_5::request_future or so_5::request_value on retained message mbox will fail. To enable service requests it is necessary to specify appropriate traits type. This traits type must contains constexpr static member of type service_request_support_t with name service_request_support. For example:

struct my_retained_msg_traits {
service_request_support =
...
};
...
const so_5::mbox_t retained_mbox =
my_retained_msg_traits>(env);

NOTE. Class with_service_request_traits_t can be used for that purpose:

Template Parameters
Traitstype with traits of mbox implementation.
Lock_Typea type of mutex to be used for protection of retained message mbox content. This must be a DefaultConstructible type with interface which allows to use Lock_Type with std::lock_guard.
Since
v.1.0.3

Definition at line 1014 of file retained_msg.hpp.