Commit b597510d authored by Dominik Charousset's avatar Dominik Charousset

Add missing getter for number of detached actors

parent e9398439
...@@ -496,6 +496,11 @@ public: ...@@ -496,6 +496,11 @@ public:
return settings_; return settings_;
} }
/// Returns the number of detached actors.
size_t detached_actors() {
return detached_.load();
}
/// @cond PRIVATE /// @cond PRIVATE
/// Increases running-detached-threads-count by one. /// Increases running-detached-threads-count by one.
...@@ -594,13 +599,13 @@ private: ...@@ -594,13 +599,13 @@ private:
std::array<strong_actor_ptr, num_internal_actors> internal_actors_; std::array<strong_actor_ptr, num_internal_actors> internal_actors_;
/// Counts the number of detached actors. /// Counts the number of detached actors.
std::atomic<size_t> detached; std::atomic<size_t> detached_;
/// Guards `detached`. /// Guards `detached`.
mutable std::mutex detached_mtx; mutable std::mutex detached_mtx_;
/// Allows waiting on specific values for `detached`. /// Allows waiting on specific values for `detached`.
mutable std::condition_variable detached_cv; mutable std::condition_variable detached_cv_;
/// The system-wide, user-provided configuration. /// The system-wide, user-provided configuration.
actor_system_config& cfg_; actor_system_config& cfg_;
......
...@@ -226,7 +226,7 @@ actor_system::actor_system(actor_system_config& cfg) ...@@ -226,7 +226,7 @@ actor_system::actor_system(actor_system_config& cfg)
groups_(*this), groups_(*this),
dummy_execution_unit_(this), dummy_execution_unit_(this),
await_actors_before_shutdown_(true), await_actors_before_shutdown_(true),
detached(0), detached_(0),
cfg_(cfg), cfg_(cfg),
logger_dtor_done_(false) { logger_dtor_done_(false) {
CAF_SET_LOGGER_SYS(this); CAF_SET_LOGGER_SYS(this);
...@@ -434,19 +434,19 @@ actor_clock& actor_system::clock() noexcept { ...@@ -434,19 +434,19 @@ actor_clock& actor_system::clock() noexcept {
} }
void actor_system::inc_detached_threads() { void actor_system::inc_detached_threads() {
++detached; ++detached_;
} }
void actor_system::dec_detached_threads() { void actor_system::dec_detached_threads() {
std::unique_lock<std::mutex> guard{detached_mtx}; std::unique_lock<std::mutex> guard{detached_mtx_};
if (--detached == 0) if (--detached_ == 0)
detached_cv.notify_all(); detached_cv_.notify_all();
} }
void actor_system::await_detached_threads() { void actor_system::await_detached_threads() {
std::unique_lock<std::mutex> guard{detached_mtx}; std::unique_lock<std::mutex> guard{detached_mtx_};
while (detached != 0) while (detached_ != 0)
detached_cv.wait(guard); detached_cv_.wait(guard);
} }
void actor_system::thread_started() { void actor_system::thread_started() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment