Commit de5c1d85 authored by Dominik Charousset's avatar Dominik Charousset

Add `make_handshake_token` to scatterer

The new function allows to get a type-erased `stream<T>` from any
scatterer. Needed to implement dynamically typed stages, e.g., based on
`fused_scatterer`.
parent b3dc91e7
...@@ -90,6 +90,10 @@ public: ...@@ -90,6 +90,10 @@ public:
return buf_.size(); return buf_.size();
} }
message make_handshake_token(stream_slot slot) const override {
return make_message(stream<T>{slot});
}
buffer_type& buf() { buffer_type& buf() {
return buf_; return buf_;
} }
......
...@@ -37,6 +37,8 @@ public: ...@@ -37,6 +37,8 @@ public:
size_t capacity() const noexcept override; size_t capacity() const noexcept override;
size_t buffered() const noexcept override; size_t buffered() const noexcept override;
message make_handshake_token(stream_slot slot) const override;
}; };
} // namespace caf } // namespace caf
......
...@@ -133,6 +133,10 @@ public: ...@@ -133,6 +133,10 @@ public:
/// Returns the size of the output buffer. /// Returns the size of the output buffer.
virtual size_t buffered() const noexcept = 0; virtual size_t buffered() const noexcept = 0;
/// Returns `make_message(stream<T>{slot})`, where `T` is the value type of
/// this scatterer.
virtual message make_handshake_token(stream_slot slot) const = 0;
// -- convenience functions -------------------------------------------------- // -- convenience functions --------------------------------------------------
/// Removes a path from the scatterer. /// Removes a path from the scatterer.
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "caf/invalid_stream_scatterer.hpp" #include "caf/invalid_stream_scatterer.hpp"
#include "caf/logger.hpp" #include "caf/logger.hpp"
#include "caf/stream.hpp"
namespace caf { namespace caf {
...@@ -47,4 +48,8 @@ size_t invalid_stream_scatterer::buffered() const noexcept { ...@@ -47,4 +48,8 @@ size_t invalid_stream_scatterer::buffered() const noexcept {
return 0u; return 0u;
} }
message invalid_stream_scatterer::make_handshake_token(stream_slot slot) const {
return make_message(stream<message>{slot});
}
} // namespace caf } // namespace caf
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