Commit dfd900c8 authored by Dominik Charousset's avatar Dominik Charousset

Integrate review feedback, fix flag handling

parent d52371cf
...@@ -47,12 +47,12 @@ public: ...@@ -47,12 +47,12 @@ public:
/// outbound paths exist. /// outbound paths exist.
static constexpr int is_continuous_flag = 0x0001; static constexpr int is_continuous_flag = 0x0001;
/// Denotes whether the stream is about to stop, only sending already /// Denotes whether the stream is about to stop, only sending buffered
/// buffered elements. /// elements.
static constexpr int is_shutting_down_flag = 0x0002; static constexpr int is_shutting_down_flag = 0x0002;
/// Denotes whether the manager has already stopped. Calling member functions /// Denotes whether the manager has stopped. Calling member functions such as
/// such as stop() or abort() on it no longer has any effect. /// stop() or abort() on it no longer has any effect.
static constexpr int is_stopped_flag = 0x0004; static constexpr int is_stopped_flag = 0x0004;
// -- member types ----------------------------------------------------------- // -- member types -----------------------------------------------------------
...@@ -147,14 +147,9 @@ public: ...@@ -147,14 +147,9 @@ public:
// -- properties ------------------------------------------------------------- // -- properties -------------------------------------------------------------
/// Returns whether this stream is shutting down. /// Returns whether this stream is neither shutting down nor has stopped.
bool shutting_down() const noexcept { bool running() const noexcept {
return getf(is_shutting_down_flag); return getf(is_shutting_down_flag | is_stopped_flag) == 0;
}
/// Returns whether this manager has already stopped.
bool stopped() const noexcept {
return getf(is_stopped_flag);
} }
/// Returns whether this stream remains open even if no in- or outbound paths /// Returns whether this stream remains open even if no in- or outbound paths
...@@ -167,7 +162,7 @@ public: ...@@ -167,7 +162,7 @@ public:
/// Sets whether this stream remains open even if no in- or outbound paths /// Sets whether this stream remains open even if no in- or outbound paths
/// exist. /// exist.
void continuous(bool x) noexcept { void continuous(bool x) noexcept {
if (!shutting_down()) { if (running()) {
if (x) if (x)
setf(is_continuous_flag); setf(is_continuous_flag);
else else
......
...@@ -125,7 +125,7 @@ void stream_manager::handle(stream_slots slots, upstream_msg::forced_drop& x) { ...@@ -125,7 +125,7 @@ void stream_manager::handle(stream_slots slots, upstream_msg::forced_drop& x) {
void stream_manager::stop(error reason) { void stream_manager::stop(error reason) {
CAF_LOG_TRACE(CAF_ARG(reason)); CAF_LOG_TRACE(CAF_ARG(reason));
if (stopped()) if (getf(is_stopped_flag))
return; return;
flags_ = is_stopped_flag; flags_ = is_stopped_flag;
if (reason) if (reason)
...@@ -138,7 +138,7 @@ void stream_manager::stop(error reason) { ...@@ -138,7 +138,7 @@ void stream_manager::stop(error reason) {
void stream_manager::shutdown() { void stream_manager::shutdown() {
CAF_LOG_TRACE(""); CAF_LOG_TRACE("");
if (getf(is_shutting_down_flag | is_stopped_flag)) if (!running())
return; return;
flags_ = is_shutting_down_flag; flags_ = is_shutting_down_flag;
CAF_LOG_DEBUG("emit shutdown messages on" CAF_LOG_DEBUG("emit shutdown messages on"
......
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