Commit a0462d6c authored by Dominik Charousset's avatar Dominik Charousset

Allow dropping of individual upstream actors

parent 97ba6743
......@@ -25,6 +25,8 @@
#include <utility>
#include "caf/fwd.hpp"
#include "caf/none.hpp"
#include "caf/error.hpp"
namespace caf {
......@@ -89,7 +91,10 @@ public:
stream_priority prio,
long downstream_credit);
bool remove_path(const strong_actor_ptr& hdl);
/// Removes `hdl` as upstream actor. The actor is removed without any further
/// signaling if `err == none`, otherwise the upstream actor receives an
/// abort message.
bool remove_path(const strong_actor_ptr& hdl, error err = none);
upstream_path* find(const strong_actor_ptr& x) const;
......
......@@ -92,7 +92,7 @@ expected<long> upstream_policy::add_path(strong_actor_ptr hdl,
return sec::upstream_already_exists;
}
bool upstream_policy::remove_path(const strong_actor_ptr& hdl) {
bool upstream_policy::remove_path(const strong_actor_ptr& hdl, error err) {
CAF_LOG_TRACE(CAF_ARG(hdl));
// Find element in our paths list.
auto has_hdl = [&](const path_uptr& x) {
......@@ -115,6 +115,9 @@ bool upstream_policy::remove_path(const strong_actor_ptr& hdl) {
// Drop path from list.
if (i != e - 1)
std::swap(*i, paths_.back());
if (err != none)
unsafe_send_as(self_, hdl, make<stream_msg::abort>(paths_.back()->sid,
std::move(err)));
paths_.pop_back();
return true;
}
......
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