Commit dae1de64 authored by Dominik Charousset's avatar Dominik Charousset

Allow typed actors to use `aout`

parent 1f0e3c52
...@@ -39,8 +39,8 @@ using pong_atom = atom_constant<atom("pong")>; ...@@ -39,8 +39,8 @@ using pong_atom = atom_constant<atom("pong")>;
using kickoff_atom = atom_constant<atom("kickoff")>; using kickoff_atom = atom_constant<atom("kickoff")>;
// utility function to print an exit message with custom name // utility function to print an exit message with custom name
void print_on_exit(const actor& ptr, const std::string& name) { void print_on_exit(const actor& hdl, const std::string& name) {
ptr->attach_functor([=](uint32_t reason) { hdl->attach_functor([=](abstract_actor* ptr, uint32_t reason) {
aout(ptr) << name << " exited with reason " << reason << endl; aout(ptr) << name << " exited with reason " << reason << endl;
}); });
} }
......
...@@ -94,9 +94,10 @@ private: ...@@ -94,9 +94,10 @@ private:
}; };
/// Convenience factory function for creating an actor output stream. /// Convenience factory function for creating an actor output stream.
inline actor_ostream aout(actor self) { actor_ostream aout(const scoped_actor& self);
return actor_ostream{self};
} /// Convenience factory function for creating an actor output stream.
actor_ostream aout(abstract_actor* self);
} // namespace caf } // namespace caf
......
...@@ -55,6 +55,14 @@ void actor_ostream::redirect_all(std::string f, int flags) { ...@@ -55,6 +55,14 @@ void actor_ostream::redirect_all(std::string f, int flags) {
redirect_atom::value, std::move(f), flags); redirect_atom::value, std::move(f), flags);
} }
actor_ostream aout(const scoped_actor& self) {
return actor_ostream{self};
}
actor_ostream aout(abstract_actor* self) {
return actor_ostream{actor_cast<actor>(intrusive_ptr<abstract_actor>{self})};
}
} // namespace caf } // namespace caf
namespace std { namespace std {
......
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