Commit a0462d6c authored by Dominik Charousset's avatar Dominik Charousset

Allow dropping of individual upstream actors

parent 97ba6743
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <utility> #include <utility>
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/none.hpp"
#include "caf/error.hpp"
namespace caf { namespace caf {
...@@ -89,7 +91,10 @@ public: ...@@ -89,7 +91,10 @@ public:
stream_priority prio, stream_priority prio,
long downstream_credit); 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; upstream_path* find(const strong_actor_ptr& x) const;
......
...@@ -92,7 +92,7 @@ expected<long> upstream_policy::add_path(strong_actor_ptr hdl, ...@@ -92,7 +92,7 @@ expected<long> upstream_policy::add_path(strong_actor_ptr hdl,
return sec::upstream_already_exists; 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)); CAF_LOG_TRACE(CAF_ARG(hdl));
// Find element in our paths list. // Find element in our paths list.
auto has_hdl = [&](const path_uptr& x) { auto has_hdl = [&](const path_uptr& x) {
...@@ -115,6 +115,9 @@ bool upstream_policy::remove_path(const strong_actor_ptr& hdl) { ...@@ -115,6 +115,9 @@ bool upstream_policy::remove_path(const strong_actor_ptr& hdl) {
// Drop path from list. // Drop path from list.
if (i != e - 1) if (i != e - 1)
std::swap(*i, paths_.back()); 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(); paths_.pop_back();
return true; 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