2
3
6
7
8
9
10
11
15#include <so_5/impl/coop_private_iface.hpp>
17#include <so_5/exception.hpp>
19#include <so_5/agent.hpp>
20#include <so_5/coop_listener.hpp>
21#include <so_5/environment_infrastructure.hpp>
23#include <so_5/stats/repository.hpp>
30#include <condition_variable>
32#if defined( SO_5_MSVC
)
34 #pragma warning(disable: 4251
)
48
49
50
51
52
63 coop_listener_unique_ptr_t coop_listener );
67
68
69
77 disp_binder_shptr_t default_binder );
87
88
89
90
91
92
93
94
95
96
104 bool total_deregistration_completed )
112
113
114
115
116
117
121 coop_shptr_t coop )
noexcept;
125
126
127
128
133
134
135
136
137
145
146
147
148
149
150
151
152
153
154
159
160
161
162
163
164
165
166
172
173
174
175
176
222
223
224
237#if defined( SO_5_MSVC
)
void call_all(environment_t &env, const coop_handle_t &coop, const coop_dereg_reason_t &reason) const noexcept
Call all notificators.
Type of smart handle for a cooperation.
bool operator!() const noexcept
Is this non-empty handle?
virtual void on_registered(environment_t &so_env, const coop_handle_t &coop) noexcept=0
Hook for the cooperation registration event.
virtual void on_deregistered(environment_t &so_env, const coop_handle_t &coop, const coop_dereg_reason_t &reason) noexcept=0
Hook for the cooperation deregistration event.
void call_all(environment_t &env, const coop_handle_t &coop) const noexcept
Call all notificators.
registration_status_t m_registration_status
The registration status of cooperation.
void deregister(int reason) noexcept
Deregister the cooperation with the specified reason.
void for_each_child(Lambda &&lambda) const
A helper method for doing some actions with children coops.
std::mutex m_lock
A lock for synchonization of some operations on coop.
registration_status_t
Registration status.
@ coop_registered
Cooperation is registered.
std::size_t size() const noexcept
Get agent count in the cooperation.
coop_handle_t handle() noexcept
Get handle for this coop.
coop_t(coop_id_t id, coop_handle_t parent, disp_binder_shptr_t coop_disp_binder, outliving_reference_t< environment_t > env)
Constructor.
A special type that plays role of unique_ptr for coop.
coop_t * operator->() const noexcept
An interface for environment_infrastructure entity.
Special guard to increment and decrement cooperation usage counters.
coop_usage_counter_guard_t(coop_t &coop)
~coop_usage_counter_guard_t()
A special class for accessing private members of agent_coop.
static coop_unique_holder_t make_coop(coop_id_t id, coop_handle_t parent, disp_binder_shptr_t default_binder, outliving_reference_t< environment_t > env)
static coop_reg_notificators_container_ref_t giveout_reg_notificators(coop_t &coop) noexcept
static void do_final_deregistration_actions(coop_t &coop)
static coop_dereg_reason_t dereg_reason(const coop_t &coop) noexcept
static void decrement_usage_count(coop_t &coop)
static coop_dereg_notificators_container_ref_t giveout_dereg_notificators(coop_t &coop) noexcept
static void increment_usage_count(coop_t &coop) noexcept
static void do_registration_specific_actions(coop_t &coop)
static coop_shptr_t make_from(coop_unique_holder_t holder) noexcept
root_coop_t(coop_id_t id, outliving_reference_t< environment_t > env)
void deregister_children_on_shutdown() noexcept
A basic part for various implementations of coop_repository.
environment_t & environment()
Access to SObjectizer Environment.
status_t m_status
Status of repository.
coop_repository_basis_t(coop_repository_basis_t &&)=delete
std::size_t m_total_coops
Total count of coops.
std::mutex m_lock
Lock for coop repository.
coop_unique_holder_t make_coop(coop_handle_t parent, disp_binder_shptr_t default_binder)
Create an instance of a new coop.
void deregister_all_coop() noexcept
Deregisted all cooperations.
outliving_reference_t< environment_t > m_env
Environment to work in.
coop_repository_basis_t(outliving_reference_t< environment_t > environment, coop_listener_unique_ptr_t coop_listener)
std::atomic_uint_fast64_t m_coop_id_counter
Counter for coop_ids.
final_deregistration_result_t final_deregister_coop(coop_shptr_t coop) noexcept
Do final actions of the cooperation deregistration.
try_switch_to_shutdown_result_t
Result of attempt to switch to shutdown state.
@ already_in_shutdown_state
coop_handle_t do_registration_specific_actions(coop_unique_holder_t coop_ptr)
An actual implementation of registration of a coop.
coop_repository_basis_t(const coop_repository_basis_t &)=delete
std::size_t m_registrations_in_progress
Count of coops those are in registration now.
environment_infrastructure_t::coop_repository_stats_t query_stats()
Get the current statistic for run-time monitoring.
status_t
Enumeration of possible repository statuses.
try_switch_to_shutdown_result_t try_switch_to_shutdown() noexcept
Try to switch repository to shutdown state.
std::shared_ptr< root_coop_t > m_root_coop
A special root coop.
coop_handle_t register_coop(coop_unique_holder_t agent_coop)
Register cooperation.
std::condition_variable m_shutdown_enabled_cond
std::size_t m_total_agents
Total count of agents.
coop_listener_unique_ptr_t m_coop_listener
Cooperation actions listener.
T * operator->() const noexcept
Helper class for indication of long-lived reference via its type.
outliving_reference_t(outliving_reference_t const &o) noexcept
#define SO_5_THROW_EXCEPTION(error_code, desc)
Enumeration of cooperation deregistration reasons.
const int shutdown
Deregistration because SObjectizer Environment shutdown.
Some reusable and low-level classes/functions which can be used in public header files.
auto invoke_noexcept_code(L lambda) noexcept -> decltype(lambda())
Details of SObjectizer run-time implementations.
Private part of message limit implementation.
const int rc_unable_to_register_coop_during_shutdown
It is impossible to register cooperation during SObjectizer Environment shutdown.
Statistical data for run-time monitoring of coop repository content.
final_deregistration_result_t(bool has_live_coop, bool total_deregistration_completed)
bool m_total_deregistration_completed