Commit a271c786 authored by Dominik Charousset's avatar Dominik Charousset

Rename has_behavior to alive

parent ea7b8e3e
......@@ -690,14 +690,9 @@ public:
// -- behavior management ----------------------------------------------------
/// Returns whether `true` if the behavior stack is not empty or
/// if outstanding responses exist, `false` otherwise.
inline bool has_behavior() const {
return !bhvr_stack_.empty()
|| !awaited_responses_.empty()
|| !multiplexed_responses_.empty()
|| !stream_managers_.empty()
|| !pending_stream_managers_.empty();
/// Returns whether `true` if the behavior stack is not empty.
inline bool has_behavior() const noexcept {
return !bhvr_stack_.empty();
}
inline behavior& current_behavior() {
......@@ -871,6 +866,19 @@ public:
/// this function again.
actor_clock::time_point advance_streams(actor_clock::time_point now);
// -- properties -------------------------------------------------------------
/// Returns `true` if the actor has a behavior, awaits responses, or
/// participates in streams.
/// @private
inline bool alive() const noexcept {
return !bhvr_stack_.empty()
|| !awaited_responses_.empty()
|| !multiplexed_responses_.empty()
|| !stream_managers_.empty()
|| !pending_stream_managers_.empty();
}
/// @endcond
protected:
......
......@@ -73,7 +73,7 @@ public:
this->setf(abstract_actor::is_initialized_flag);
auto bhvr = make_behavior();
CAF_LOG_DEBUG_IF(!bhvr, "make_behavior() did not return a behavior:"
<< CAF_ARG(this->has_behavior()));
<< CAF_ARG2("alive", this->alive()));
if (bhvr) {
// make_behavior() did return a behavior instead of using become()
CAF_LOG_DEBUG("make_behavior() did return a valid behavior");
......
......@@ -38,7 +38,7 @@ void event_based_actor::initialize() {
setf(is_initialized_flag);
auto bhvr = make_behavior();
CAF_LOG_DEBUG_IF(!bhvr, "make_behavior() did not return a behavior:"
<< CAF_ARG(has_behavior()));
<< CAF_ARG2("alive", alive()));
if (bhvr) {
// make_behavior() did return a behavior instead of using become()
CAF_LOG_DEBUG("make_behavior() did return a valid behavior");
......
......@@ -680,10 +680,8 @@ bool scheduled_actor::activate(execution_unit* ctx) {
CAF_ASSERT(ctx != nullptr);
CAF_ASSERT(!getf(is_blocking_flag));
context(ctx);
if (getf(is_initialized_flag)
&& (!has_behavior() || getf(is_terminated_flag))) {
CAF_LOG_DEBUG_IF(!has_behavior(),
"resume called on an actor without behavior");
if (getf(is_initialized_flag) && (!alive() || getf(is_terminated_flag))) {
CAF_LOG_DEBUG_IF(!alive(), "resume called on an actor without behavior");
CAF_LOG_DEBUG_IF(getf(is_terminated_flag),
"resume called on a terminated actor");
return false;
......@@ -781,7 +779,7 @@ bool scheduled_actor::finalize() {
return true;
// An actor is considered alive as long as it has a behavior and didn't set
// the terminated flag.
if (has_behavior() && !getf(is_terminated_flag))
if (alive() && !getf(is_terminated_flag))
return false;
CAF_LOG_DEBUG("actor either has no behavior or has set an exit reason");
on_exit();
......
......@@ -96,7 +96,7 @@ public:
this->init_broker();
auto bhvr = make_behavior();
CAF_LOG_DEBUG_IF(!bhvr, "make_behavior() did not return a behavior:"
<< CAF_ARG(this->has_behavior()));
<< CAF_ARG2("alive", this->alive()));
if (bhvr) {
// make_behavior() did return a behavior instead of using become()
CAF_LOG_DEBUG("make_behavior() did return a valid behavior");
......
......@@ -37,7 +37,7 @@ void broker::initialize() {
init_broker();
auto bhvr = make_behavior();
CAF_LOG_DEBUG_IF(!bhvr, "make_behavior() did not return a behavior:"
<< CAF_ARG(has_behavior()));
<< CAF_ARG2("alive", alive()));
if (bhvr) {
// make_behavior() did return a behavior instead of using become()
CAF_LOG_DEBUG("make_behavior() did return a valid behavior");
......
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