Commit 3d927140 authored by Dominik Charousset's avatar Dominik Charousset

Merge branch 'topic/detached-actors'

parents c57d18c2 b597510d
......@@ -496,6 +496,11 @@ public:
return settings_;
}
/// Returns the number of detached actors.
size_t detached_actors() {
return detached_.load();
}
/// @cond PRIVATE
/// Increases running-detached-threads-count by one.
......@@ -594,13 +599,13 @@ private:
std::array<strong_actor_ptr, num_internal_actors> internal_actors_;
/// Counts the number of detached actors.
std::atomic<size_t> detached;
std::atomic<size_t> detached_;
/// Guards `detached`.
mutable std::mutex detached_mtx;
mutable std::mutex detached_mtx_;
/// 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.
actor_system_config& cfg_;
......
......@@ -226,7 +226,7 @@ actor_system::actor_system(actor_system_config& cfg)
groups_(*this),
dummy_execution_unit_(this),
await_actors_before_shutdown_(true),
detached(0),
detached_(0),
cfg_(cfg),
logger_dtor_done_(false) {
CAF_SET_LOGGER_SYS(this);
......@@ -434,19 +434,19 @@ actor_clock& actor_system::clock() noexcept {
}
void actor_system::inc_detached_threads() {
++detached;
++detached_;
}
void actor_system::dec_detached_threads() {
std::unique_lock<std::mutex> guard{detached_mtx};
if (--detached == 0)
detached_cv.notify_all();
std::unique_lock<std::mutex> guard{detached_mtx_};
if (--detached_ == 0)
detached_cv_.notify_all();
}
void actor_system::await_detached_threads() {
std::unique_lock<std::mutex> guard{detached_mtx};
while (detached != 0)
detached_cv.wait(guard);
std::unique_lock<std::mutex> guard{detached_mtx_};
while (detached_ != 0)
detached_cv_.wait(guard);
}
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