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

Namespaces

 details
 
 errors
 

Classes

struct  default_traits_t
 Default traits 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...
 

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, ...);
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 726 of file retained_msg.hpp.