Commit e47c5a49 authored by Dominik Charousset's avatar Dominik Charousset

Fix aout(self) in composable behaviors, close #496

parent 46fec1c8
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "caf/actor.hpp" #include "caf/actor.hpp"
#include "caf/deep_to_string.hpp" #include "caf/deep_to_string.hpp"
#include "caf/typed_actor_pointer.hpp"
namespace caf { namespace caf {
...@@ -46,6 +47,12 @@ public: ...@@ -46,6 +47,12 @@ public:
explicit actor_ostream(scoped_actor& self); explicit actor_ostream(scoped_actor& self);
template <class... Sigs>
explicit actor_ostream(const typed_actor_pointer<Sigs...>& ptr)
: actor_ostream(ptr.internal_ptr()) {
// nop
}
/// Writes `arg` to the buffer allocated for the calling actor. /// Writes `arg` to the buffer allocated for the calling actor.
actor_ostream& write(std::string arg); actor_ostream& write(std::string arg);
...@@ -95,6 +102,12 @@ actor_ostream aout(local_actor* self); ...@@ -95,6 +102,12 @@ actor_ostream aout(local_actor* self);
/// Convenience factory function for creating an actor output stream. /// Convenience factory function for creating an actor output stream.
actor_ostream aout(scoped_actor& self); actor_ostream aout(scoped_actor& self);
/// Convenience factory function for creating an actor output stream.
template <class... Sigs>
actor_ostream aout(const typed_actor_pointer<Sigs...>& ptr) {
return actor_ostream{ptr};
}
} // namespace caf } // namespace caf
namespace std { namespace std {
......
...@@ -55,6 +55,11 @@ public: ...@@ -55,6 +55,11 @@ public:
return view_.ctrl(); return view_.ctrl();
} }
/// @private
scheduled_actor* internal_ptr() const {
return view_.internal_ptr();
}
template <class Supertype> template <class Supertype>
typed_actor_pointer& operator=(Supertype* ptr) { typed_actor_pointer& operator=(Supertype* ptr) {
using namespace caf::detail; using namespace caf::detail;
......
...@@ -114,6 +114,11 @@ public: ...@@ -114,6 +114,11 @@ public:
return actor_control_block::from(self_);; return actor_control_block::from(self_);;
} }
/// @private
scheduled_actor* internal_ptr() const {
return self_;
}
private: private:
scheduled_actor* self_; scheduled_actor* self_;
}; };
......
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