Commit a4e4c4ff authored by Dominik Charousset's avatar Dominik Charousset

Move actor decorators to a separate namespace

parent af4f3410
...@@ -25,6 +25,7 @@ set (LIBCAF_CORE_SRCS ...@@ -25,6 +25,7 @@ set (LIBCAF_CORE_SRCS
src/actor_registry.cpp src/actor_registry.cpp
src/actor_system.cpp src/actor_system.cpp
src/actor_system_config.cpp src/actor_system_config.cpp
src/adapter.cpp
src/atom.cpp src/atom.cpp
src/attachable.cpp src/attachable.cpp
src/behavior.cpp src/behavior.cpp
...@@ -33,9 +34,7 @@ set (LIBCAF_CORE_SRCS ...@@ -33,9 +34,7 @@ set (LIBCAF_CORE_SRCS
src/binary_deserializer.cpp src/binary_deserializer.cpp
src/binary_serializer.cpp src/binary_serializer.cpp
src/blocking_actor.cpp src/blocking_actor.cpp
src/bound_actor.cpp
src/channel.cpp src/channel.cpp
src/composed_actor.cpp
src/concatenated_tuple.cpp src/concatenated_tuple.cpp
src/continue_helper.cpp src/continue_helper.cpp
src/decorated_tuple.cpp src/decorated_tuple.cpp
...@@ -80,6 +79,7 @@ set (LIBCAF_CORE_SRCS ...@@ -80,6 +79,7 @@ set (LIBCAF_CORE_SRCS
src/scoped_execution_unit.cpp src/scoped_execution_unit.cpp
src/sec.cpp src/sec.cpp
src/serializer.cpp src/serializer.cpp
src/sequencer.cpp
src/shared_spinlock.cpp src/shared_spinlock.cpp
src/sync_request_bouncer.cpp src/sync_request_bouncer.cpp
src/try_match.cpp src/try_match.cpp
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include "caf/replies_to.hpp" #include "caf/replies_to.hpp"
#include "caf/serializer.hpp" #include "caf/serializer.hpp"
#include "caf/actor_proxy.hpp" #include "caf/actor_proxy.hpp"
#include "caf/bound_actor.hpp"
#include "caf/exit_reason.hpp" #include "caf/exit_reason.hpp"
#include "caf/local_actor.hpp" #include "caf/local_actor.hpp"
#include "caf/ref_counted.hpp" #include "caf/ref_counted.hpp"
...@@ -62,7 +61,6 @@ ...@@ -62,7 +61,6 @@
#include "caf/abstract_actor.hpp" #include "caf/abstract_actor.hpp"
#include "caf/abstract_group.hpp" #include "caf/abstract_group.hpp"
#include "caf/blocking_actor.hpp" #include "caf/blocking_actor.hpp"
#include "caf/composed_actor.hpp"
#include "caf/deep_to_string.hpp" #include "caf/deep_to_string.hpp"
#include "caf/execution_unit.hpp" #include "caf/execution_unit.hpp"
#include "caf/memory_managed.hpp" #include "caf/memory_managed.hpp"
...@@ -90,6 +88,9 @@ ...@@ -90,6 +88,9 @@
#include "caf/typed_continue_helper.hpp" #include "caf/typed_continue_helper.hpp"
#include "caf/typed_event_based_actor.hpp" #include "caf/typed_event_based_actor.hpp"
#include "caf/decorator/adapter.hpp"
#include "caf/decorator/sequencer.hpp"
#include "caf/scheduler/abstract_coordinator.hpp" #include "caf/scheduler/abstract_coordinator.hpp"
/// @author Dominik Charousset <dominik.charousset (at) haw-hamburg.de> /// @author Dominik Charousset <dominik.charousset (at) haw-hamburg.de>
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#ifndef CAF_BOUND_ACTOR_HPP #ifndef CAF_DECORATOR_ADAPTER_HPP
#define CAF_BOUND_ACTOR_HPP #define CAF_DECORATOR_ADAPTER_HPP
#include "caf/message.hpp" #include "caf/message.hpp"
#include "caf/actor_addr.hpp" #include "caf/actor_addr.hpp"
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "caf/monitorable_actor.hpp" #include "caf/monitorable_actor.hpp"
namespace caf { namespace caf {
namespace decorator {
/// An actor decorator implementing `std::bind`-like compositions. /// An actor decorator implementing `std::bind`-like compositions.
/// Bound actors are hidden actors. A bound actor exits when its /// Bound actors are hidden actors. A bound actor exits when its
...@@ -33,9 +34,9 @@ namespace caf { ...@@ -33,9 +34,9 @@ namespace caf {
/// on the bound actor by default, and exit of a bound actor has /// on the bound actor by default, and exit of a bound actor has
/// no effect on the decorated actor. Bound actors are hosted on /// no effect on the decorated actor. Bound actors are hosted on
/// the same actor system and node as decorated actors. /// the same actor system and node as decorated actors.
class bound_actor : public monitorable_actor { class adapter : public monitorable_actor {
public: public:
bound_actor(actor_addr decorated, message msg); adapter(actor_addr decorated, message msg);
// non-system messages are processed and then forwarded; // non-system messages are processed and then forwarded;
// system messages are handled and consumed on the spot; // system messages are handled and consumed on the spot;
...@@ -47,6 +48,7 @@ private: ...@@ -47,6 +48,7 @@ private:
message merger_; message merger_;
}; };
} // namespace decorator
} // namespace caf } // namespace caf
#endif // CAF_BOUND_ACTOR_HPP #endif // CAF_DECORATOR_ADAPTER_HPP
...@@ -17,14 +17,15 @@ ...@@ -17,14 +17,15 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#ifndef CAF_COMPOSED_ACTOR_HPP #ifndef CAF_DECORATOR_SEQUENCER_HPP
#define CAF_COMPOSED_ACTOR_HPP #define CAF_DECORATOR_SEQUENCER_HPP
#include "caf/actor_addr.hpp" #include "caf/actor_addr.hpp"
#include "caf/mailbox_element.hpp" #include "caf/mailbox_element.hpp"
#include "caf/monitorable_actor.hpp" #include "caf/monitorable_actor.hpp"
namespace caf { namespace caf {
namespace decorator {
/// An actor decorator implementing "dot operator"-like compositions, /// An actor decorator implementing "dot operator"-like compositions,
/// i.e., `f.g(x) = f(g(x))`. Composed actors are hidden actors. /// i.e., `f.g(x) = f(g(x))`. Composed actors are hidden actors.
...@@ -33,11 +34,11 @@ namespace caf { ...@@ -33,11 +34,11 @@ namespace caf {
/// by default, and exit of a composed actor has no effect on its /// by default, and exit of a composed actor has no effect on its
/// constituent actors. A composed actor is hosted on the same actor /// constituent actors. A composed actor is hosted on the same actor
/// system and node as `g`, the first actor on the forwarding chain. /// system and node as `g`, the first actor on the forwarding chain.
class composed_actor : public monitorable_actor { class sequencer : public monitorable_actor {
public: public:
using message_types_set = std::set<std::string>; using message_types_set = std::set<std::string>;
composed_actor(actor_addr f, actor_addr g, message_types_set msg_types); sequencer(actor_addr f, actor_addr g, message_types_set msg_types);
// non-system messages are processed and then forwarded; // non-system messages are processed and then forwarded;
// system messages are handled and consumed on the spot; // system messages are handled and consumed on the spot;
...@@ -52,6 +53,7 @@ private: ...@@ -52,6 +53,7 @@ private:
message_types_set msg_types_; message_types_set msg_types_;
}; };
} // namespace decorator
} // namespace caf } // namespace caf
#endif // CAF_COMPOSED_ACTOR_HPP #endif // CAF_DECORATOR_SEQUENCER_HPP
...@@ -25,13 +25,14 @@ ...@@ -25,13 +25,14 @@
#include "caf/actor.hpp" #include "caf/actor.hpp"
#include "caf/actor_cast.hpp" #include "caf/actor_cast.hpp"
#include "caf/replies_to.hpp" #include "caf/replies_to.hpp"
#include "caf/bound_actor.hpp"
#include "caf/abstract_actor.hpp" #include "caf/abstract_actor.hpp"
#include "caf/composed_actor.hpp"
#include "caf/stateful_actor.hpp" #include "caf/stateful_actor.hpp"
#include "caf/typed_behavior.hpp" #include "caf/typed_behavior.hpp"
#include "caf/typed_response_promise.hpp" #include "caf/typed_response_promise.hpp"
#include "caf/decorator/adapter.hpp"
#include "caf/decorator/sequencer.hpp"
#include "caf/detail/mpi_bind.hpp" #include "caf/detail/mpi_bind.hpp"
#include "caf/detail/mpi_composition.hpp" #include "caf/detail/mpi_composition.hpp"
...@@ -215,8 +216,8 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>, ...@@ -215,8 +216,8 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
bind(Ts&&... xs) const { bind(Ts&&... xs) const {
if (! ptr_) if (! ptr_)
return invalid_actor; return invalid_actor;
auto ptr = make_counted<bound_actor>(ptr_->address(), auto ptr = make_counted<decorator::adapter>(ptr_->address(),
make_message(xs...)); make_message(xs...));
return {ptr.release(), false}; return {ptr.release(), false};
} }
...@@ -298,10 +299,9 @@ operator*(typed_actor<Xs...> f, typed_actor<Ys...> g) { ...@@ -298,10 +299,9 @@ operator*(typed_actor<Xs...> f, typed_actor<Ys...> g) {
detail::type_list<Xs...>, detail::type_list<Xs...>,
Ys... Ys...
>::type; >::type;
auto ptr = make_counted<composed_actor>(f.address(), auto mts = g->home_system().message_types(result{});
g.address(), auto ptr = make_counted<decorator::sequencer>(f.address(), g.address(),
g->home_system().message_types( std::move(mts));
result{}));
return actor_cast<result>(std::move(ptr)); return actor_cast<result>(std::move(ptr));
} }
......
...@@ -25,13 +25,14 @@ ...@@ -25,13 +25,14 @@
#include "caf/actor_addr.hpp" #include "caf/actor_addr.hpp"
#include "caf/serializer.hpp" #include "caf/serializer.hpp"
#include "caf/actor_proxy.hpp" #include "caf/actor_proxy.hpp"
#include "caf/bound_actor.hpp"
#include "caf/local_actor.hpp" #include "caf/local_actor.hpp"
#include "caf/deserializer.hpp" #include "caf/deserializer.hpp"
#include "caf/blocking_actor.hpp" #include "caf/blocking_actor.hpp"
#include "caf/composed_actor.hpp"
#include "caf/event_based_actor.hpp" #include "caf/event_based_actor.hpp"
#include "caf/decorator/adapter.hpp"
#include "caf/decorator/sequencer.hpp"
namespace caf { namespace caf {
actor::actor(const invalid_actor_t&) : ptr_(nullptr) { actor::actor(const invalid_actor_t&) : ptr_(nullptr) {
...@@ -78,16 +79,16 @@ actor_id actor::id() const noexcept { ...@@ -78,16 +79,16 @@ actor_id actor::id() const noexcept {
actor actor::bind_impl(message msg) const { actor actor::bind_impl(message msg) const {
if (! ptr_) if (! ptr_)
return invalid_actor; return invalid_actor;
return actor_cast<actor>(make_counted<bound_actor>(address(), return actor_cast<actor>(make_counted<decorator::adapter>(address(),
std::move(msg))); std::move(msg)));
} }
actor operator*(actor f, actor g) { actor operator*(actor f, actor g) {
if (! f || ! g) if (! f || ! g)
return invalid_actor; return invalid_actor;
auto ptr = make_counted<composed_actor>(f.address(), auto ptr = make_counted<decorator::sequencer>(f.address(),
g.address(), g.address(),
std::set<std::string>{}); std::set<std::string>{});
return actor_cast<actor>(std::move(ptr)); return actor_cast<actor>(std::move(ptr));
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#include "caf/bound_actor.hpp" #include "caf/decorator/adapter.hpp"
#include "caf/sec.hpp" #include "caf/sec.hpp"
#include "caf/actor_cast.hpp" #include "caf/actor_cast.hpp"
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
#include "caf/detail/sync_request_bouncer.hpp" #include "caf/detail/sync_request_bouncer.hpp"
namespace caf { namespace caf {
namespace decorator {
bound_actor::bound_actor(actor_addr decorated, message msg) adapter::adapter(actor_addr decorated, message msg)
: monitorable_actor(&decorated->home_system(), : monitorable_actor(&decorated->home_system(),
decorated->home_system().next_actor_id(), decorated->home_system().next_actor_id(),
decorated->node(), decorated->node(),
...@@ -46,8 +47,7 @@ bound_actor::bound_actor(actor_addr decorated, message msg) ...@@ -46,8 +47,7 @@ bound_actor::bound_actor(actor_addr decorated, message msg)
decorated_->attach(default_attachable::make_monitor(address())); decorated_->attach(default_attachable::make_monitor(address()));
} }
void bound_actor::enqueue(mailbox_element_ptr what, void adapter::enqueue(mailbox_element_ptr what, execution_unit* host) {
execution_unit* host) {
if (! what) if (! what)
return; // not even an empty message return; // not even an empty message
auto reason = exit_reason_.load(); auto reason = exit_reason_.load();
...@@ -81,4 +81,5 @@ void bound_actor::enqueue(mailbox_element_ptr what, ...@@ -81,4 +81,5 @@ void bound_actor::enqueue(mailbox_element_ptr what,
decorated_->enqueue(std::move(what), host); decorated_->enqueue(std::move(what), host);
} }
} // namespace decorator
} // namespace caf } // namespace caf
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#include "caf/composed_actor.hpp" #include "caf/decorator/sequencer.hpp"
#include "caf/actor_system.hpp" #include "caf/actor_system.hpp"
#include "caf/default_attachable.hpp" #include "caf/default_attachable.hpp"
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
#include "caf/detail/sync_request_bouncer.hpp" #include "caf/detail/sync_request_bouncer.hpp"
namespace caf { namespace caf {
namespace decorator {
composed_actor::composed_actor(actor_addr f, actor_addr g, sequencer::sequencer(actor_addr f, actor_addr g, message_types_set msg_types)
message_types_set msg_types)
: monitorable_actor(&g->home_system(), : monitorable_actor(&g->home_system(),
g->home_system().next_actor_id(), g->home_system().next_actor_id(),
g->node(), g->node(),
...@@ -44,7 +44,7 @@ composed_actor::composed_actor(actor_addr f, actor_addr g, ...@@ -44,7 +44,7 @@ composed_actor::composed_actor(actor_addr f, actor_addr g,
g_->attach(default_attachable::make_monitor(address())); g_->attach(default_attachable::make_monitor(address()));
} }
void composed_actor::enqueue(mailbox_element_ptr what, void sequencer::enqueue(mailbox_element_ptr what,
execution_unit* context) { execution_unit* context) {
if (! what) if (! what)
return; // not even an empty message return; // not even an empty message
...@@ -80,8 +80,9 @@ void composed_actor::enqueue(mailbox_element_ptr what, ...@@ -80,8 +80,9 @@ void composed_actor::enqueue(mailbox_element_ptr what,
g_->enqueue(std::move(what), context); g_->enqueue(std::move(what), context);
} }
composed_actor::message_types_set composed_actor::message_types() const { sequencer::message_types_set sequencer::message_types() const {
return msg_types_; return msg_types_;
} }
} // namespace decorator
} // namespace caf } // namespace caf
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "caf/config.hpp" #include "caf/config.hpp"
#define CAF_SUITE bound_actor #define CAF_SUITE adapter
#include "caf/test/unit_test.hpp" #include "caf/test/unit_test.hpp"
#include "caf/all.hpp" #include "caf/all.hpp"
...@@ -62,7 +62,7 @@ struct fixture { ...@@ -62,7 +62,7 @@ struct fixture {
} // namespace <anonymous> } // namespace <anonymous>
CAF_TEST_FIXTURE_SCOPE(bound_actor_tests, fixture) CAF_TEST_FIXTURE_SCOPE(adapter_tests, fixture)
CAF_TEST(identity) { CAF_TEST(identity) {
auto dbl = system.spawn(dbl_bhvr); auto dbl = system.spawn(dbl_bhvr);
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "caf/config.hpp" #include "caf/config.hpp"
#define CAF_SUITE composed_actor #define CAF_SUITE sequencer
#include "caf/test/unit_test.hpp" #include "caf/test/unit_test.hpp"
#include "caf/all.hpp" #include "caf/all.hpp"
...@@ -77,7 +77,7 @@ struct fixture { ...@@ -77,7 +77,7 @@ struct fixture {
} // namespace <anonymous> } // namespace <anonymous>
CAF_TEST_FIXTURE_SCOPE(composed_actor_tests, fixture) CAF_TEST_FIXTURE_SCOPE(sequencer_tests, fixture)
CAF_TEST(identity) { CAF_TEST(identity) {
actor_system system_of_g; actor_system system_of_g;
......
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