2
3
6
7
8
9
10
12#include <so_5/impl/mt_env_infrastructure.hpp>
14#include <so_5/impl/run_stage.hpp>
15#include <so_5/impl/internal_env_iface.hpp>
17#include <so_5/environment.hpp>
18#include <so_5/send_functions.hpp>
20#include <so_5/disp/one_thread/pub.hpp>
35 coop_listener_unique_ptr_t coop_listener )
44 m_final_dereg_thread = std::thread{ [
this] { final_dereg_thread_body(); } };
58 std::lock_guard< std::mutex > lock{ m_final_dereg_chain_lock };
60 m_final_dereg_chain_cond.notify_one();
62 m_final_dereg_thread.join();
69 std::lock_guard< std::mutex > lck{ m_final_dereg_chain_lock };
72 m_final_dereg_chain.append( std::move(coop) );
74 if( 1u == m_final_dereg_chain.size() )
77 m_final_dereg_chain_cond.notify_one();
83 coop_shptr_t coop )
noexcept
86 coop_repository_basis_t::final_deregister_coop( std::move(coop) );
88 if( result.m_total_deregistration_completed )
89 m_deregistration_finished_cond.notify_one();
91 return result.m_has_live_coop;
99 if( coop_repository_basis_t::try_switch_to_shutdown_result_t
100 ::switched == result )
101 m_deregistration_started_cond.notify_one();
107 std::unique_lock< std::mutex > lck{ m_lock };
109 m_deregistration_started_cond.wait( lck,
110 [
this] {
return status_t::normal != m_status; } );
116 std::unique_lock< std::mutex > lck{ m_lock };
120 m_deregistration_finished_cond.wait( lck,
121 [
this] {
return 0u == m_total_coops; } );
127 const auto final_dereg_coops = [
this]() {
128 std::lock_guard< std::mutex > lck{ m_final_dereg_chain_lock };
129 return m_final_dereg_chain.size();
135 basis_stats.m_total_coop_count,
136 basis_stats.m_total_agent_count,
144 std::unique_lock< std::mutex > lck{ m_final_dereg_chain_lock };
146 for(
bool should_continue =
true; should_continue; )
148 bool should_wait =
true;
152 if( !m_final_dereg_chain.empty() )
155 process_current_final_dereg_chain( lck );
165 should_continue =
false;
167 else if( should_wait )
170 m_final_dereg_chain_cond.wait( lck );
176coop_repo_t::process_current_final_dereg_chain(
400 "run_default_dispatcher",
469 environment_params_t & params,
470 mbox_t stats_distribution_mbox )
474 so_5::internal_timer_helpers::create_appropriate_timer_thread(
475 params.so5_error_logger(),
476 params.so5_giveout_timer_thread_factory() );
479 auto obj =
new impl::mt_env_infrastructure_t(
481 params.default_disp_params(),
483 params.so5_giveout_coop_listener(),
484 std::move(stats_distribution_mbox) );
486 return environment_infrastructure_unique_ptr_t(
488 environment_infrastructure_t::default_deleter() );
void start_deregistration()
Initiate start of the cooperation deregistration.
void ready_to_deregister_notify(coop_shptr_t coop)
Notification about readiness of the cooperation deregistration.
bool final_deregister_coop(coop_shptr_t coop) noexcept
Do final actions of the cooperation deregistration.
coop_repo_t(outliving_reference_t< environment_t > env, coop_listener_unique_ptr_t coop_listener)
Initializing constructor.
void wait_all_coop_to_deregister()
Wait for end of all cooperations deregistration.
void start()
Do initialization.
void final_dereg_thread_body()
Method that implements the body of final deregistration thread.
bool m_final_dereg_thread_shutdown_flag
The flag for shutting down the final deregistration thread.
environment_infrastructure_t::coop_repository_stats_t query_stats()
Get the current statistic for run-time monitoring.
void finish()
Finish work.
void wait_for_start_deregistration()
Wait for a signal about start of the cooperation deregistration.
An interface for environment_infrastructure entity.
A basic part for various implementations of coop_repository.
void deregister_all_coop() noexcept
Deregisted all cooperations.
environment_infrastructure_t::coop_repository_stats_t query_stats()
Get the current statistic for run-time monitoring.
try_switch_to_shutdown_result_t try_switch_to_shutdown() noexcept
Try to switch repository to shutdown state.
Helper class for indication of long-lived reference via its type.
Default multi-threaded environment infrastructure.
SO_5_FUNC environment_infrastructure_factory_t factory()
A factory for creation the default multitheading environment infrastructure.
Various implementations of environment_infrastructure.
Private part of message limit implementation.
Statistical data for run-time monitoring of coop repository content.