[idea] Registration of user-provided mboxes as named ones
eao197 opened this issue · comments
The current version of environment_t::create_mbox(name)
always returns a mbox created by SObjectizer. It seems that we can provide a possibility to user to register own mbox as a named one.
Something like:
so_5::mbox_t custom_mbox = so_5::extra::mboxes::unique_subscribers::make(env);
env.register_named_mbox("my_mbox", custom_mbox);
...
auto mbox = env.create_mbox("my_mbox"); // the custom_mbox will be returned.
The changes to SObjectizer can look like:
namespace so_5
{
namespace named_mbox
{
enum class not_unique_name_reaction_t
{
throw_exception,
dont_throw_exception
};
constexpr auto throw_if_not_unique = not_unique_name_reaction_t::throw_exception;
constexpr auto nothrow_if_not_unique = not_unique_name_reaction_t::dont_throw_exception;
} /* namespace named_mbox */
class environment_t
{
public:
...
// Returns false if name isn't unique and reaction is dont_throw_if_not_unique.
bool
register_named_mbox(nonempty_name_t mbox_name,
named_mbox::not_unique_name_reaction_t reaction = named_mbox::throw_if_not_unique);
...
};
} /* namespace so_5 */
Implemented in v.5.8.0.