Commit 606bbecf authored by Benno Evers's avatar Benno Evers

Print actor id when adjusting running count

This can speed up debugging for errors where the running
count does not reach zero at program shutdown but it
is not clear which actor is still alive.
parent b3478a09
......@@ -65,11 +65,11 @@ public:
/// leaving `reason` for future reference.
void erase(actor_id key);
/// Increases running-actors-count by one.
void inc_running();
/// Increases running-actors-count by one. Returns the increased count.
size_t inc_running();
/// Decreases running-actors-count by one.
void dec_running();
/// Decreases running-actors-count by one. Returns the decreased count.
size_t dec_running();
/// Returns the number of currently running actors.
size_t running() const;
......
......@@ -95,14 +95,16 @@ void abstract_actor::register_at_system() {
if (getf(is_registered_flag))
return;
setf(is_registered_flag);
home_system().registry().inc_running();
[[maybe_unused]] auto count = home_system().registry().inc_running();
CAF_LOG_DEBUG("actor " << id() << " increased running count to " << count);
}
void abstract_actor::unregister_from_system() {
if (!getf(is_registered_flag))
return;
unsetf(is_registered_flag);
home_system().registry().dec_running();
[[maybe_unused]] auto count = home_system().registry().dec_running();
CAF_LOG_DEBUG("actor " << id() << " decreased running count to " << count);
}
} // namespace caf
......@@ -94,26 +94,21 @@ void actor_registry::erase(actor_id key) {
}
}
void actor_registry::inc_running() {
# if CAF_LOG_LEVEL >= CAF_LOG_LEVEL_DEBUG
auto value = ++*system_.base_metrics().running_actors;
CAF_LOG_DEBUG(CAF_ARG(value));
# else
system_.base_metrics().running_actors->inc();
# endif
size_t actor_registry::inc_running() {
return ++*system_.base_metrics().running_actors;
}
size_t actor_registry::running() const {
return static_cast<size_t>(system_.base_metrics().running_actors->value());
}
void actor_registry::dec_running() {
size_t actor_registry::dec_running() {
size_t new_val = --*system_.base_metrics().running_actors;
if (new_val <= 1) {
std::unique_lock<std::mutex> guard(running_mtx_);
running_cv_.notify_all();
}
CAF_LOG_DEBUG(CAF_ARG(new_val));
return new_val;
}
void actor_registry::await_running_count_equal(size_t expected) const {
......
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