Skip to content

Commit

Permalink
Integrate review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dominiklohmann committed Jan 17, 2024
1 parent 827ce03 commit bf88d1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion libcaf_core/caf/actor_control_block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ CAF_CORE_EXPORT void intrusive_ptr_release_weak(actor_control_block* x);

/// @relates actor_control_block
inline void intrusive_ptr_add_ref(actor_control_block* x) {
x->strong_refs.fetch_add(1, std::memory_order_relaxed);
if (CAF_UNLIKELY(x->strong_refs.fetch_add(1, std::memory_order_relaxed) == 0)) {
CAF_CRITICAL("increased the strong reference count of an expired actor");
}
}

/// @relates actor_control_block
Expand Down
11 changes: 7 additions & 4 deletions libcaf_core/src/response_promise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,16 @@ void response_promise::state::cancel() {
void response_promise::state::deliver_impl(message msg) {
CAF_LOG_TRACE(CAF_ARG(msg));
auto cancel_guard = detail::make_scope_guard([this] {
cancel();
});
cancel();
});
if (msg.empty() && id.is_async()) {
CAF_LOG_DEBUG("drop response: empty response to asynchronous input");
return;
}
if (source == nullptr) {
CAF_LOG_DEBUG("drop response: source is nullptr");
return;
}
auto self = weak_self.lock();
if (self == nullptr) {
auto element = make_mailbox_element(self, id.response_id(),
Expand All @@ -181,15 +185,14 @@ void response_promise::state::deliver_impl(message msg) {
source->enqueue(std::move(element), nullptr);
return;
}
auto local_self = static_cast<local_actor*>(weak_self.get()->get());
auto local_self = static_cast<local_actor*>(self->get());
if (!stages.empty()) {
auto next = std::move(stages.back());
stages.pop_back();
detail::profiled_send(local_self, std::move(source), next, id, std::move(stages),
local_self->context(), std::move(msg));
return;
}
CAF_ASSERT(source != nullptr);
detail::profiled_send(local_self, local_self->ctrl(), source, id.response_id(),
forwarding_stack{}, local_self->context(), std::move(msg));
}
Expand Down

0 comments on commit bf88d1c

Please sign in to comment.