Commit ade02937 authored by Dominik Charousset's avatar Dominik Charousset

Move `detail::disposer` to its own header

parent 963a0bc8
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "caf/mixin/sync_sender.hpp" #include "caf/mixin/sync_sender.hpp"
#include "caf/mixin/behavior_stack_based.hpp" #include "caf/mixin/behavior_stack_based.hpp"
#include "caf/detail/memory.hpp" #include "caf/detail/disposer.hpp"
#include "caf/detail/shared_spinlock.hpp" #include "caf/detail/shared_spinlock.hpp"
namespace caf { namespace caf {
...@@ -39,16 +39,13 @@ namespace caf { ...@@ -39,16 +39,13 @@ namespace caf {
* callback to another object, thus serving as gateway to * callback to another object, thus serving as gateway to
* allow any object to interact with other actors. * allow any object to interact with other actors.
*/ */
class actor_companion : public extend<local_actor, actor_companion>:: class actor_companion
with<mixin::behavior_stack_based<behavior>::impl, : public extend<local_actor, actor_companion>::
mixin::sync_sender<nonblocking_response_handle_tag>::impl> { with<mixin::behavior_stack_based<behavior>::impl,
mixin::sync_sender<nonblocking_response_handle_tag>::impl> {
using lock_type = detail::shared_spinlock;
public: public:
using lock_type = detail::shared_spinlock;
using message_pointer = std::unique_ptr<mailbox_element, detail::disposer>; using message_pointer = std::unique_ptr<mailbox_element, detail::disposer>;
using enqueue_handler = std::function<void (message_pointer)>; using enqueue_handler = std::function<void (message_pointer)>;
/** /**
...@@ -64,16 +61,14 @@ class actor_companion : public extend<local_actor, actor_companion>:: ...@@ -64,16 +61,14 @@ class actor_companion : public extend<local_actor, actor_companion>::
void on_enqueue(enqueue_handler handler); void on_enqueue(enqueue_handler handler);
void enqueue(const actor_addr& sender, message_id mid, void enqueue(const actor_addr& sender, message_id mid,
message content, execution_unit* host) override; message content, execution_unit* host) override;
private: private:
// set by parent to define custom enqueue action // set by parent to define custom enqueue action
enqueue_handler m_on_enqueue; enqueue_handler m_on_enqueue;
// guards access to m_handler // guards access to m_handler
lock_type m_lock; lock_type m_lock;
}; };
/** /**
......
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2014 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_DETAIL_DISPOSER_HPP
#define CAF_DETAIL_DISPOSER_HPP
#include "caf/memory_managed.hpp"
namespace caf {
namespace detail {
class disposer {
public:
inline void operator()(memory_managed* ptr) const {
ptr->request_deletion();
}
};
} // namespace detail
} // namespace caf
#endif // CAF_DETAIL_DISPOSER_HPP
...@@ -45,13 +45,6 @@ constexpr size_t s_max_elements = 20; // don't create > 20 elements ...@@ -45,13 +45,6 @@ constexpr size_t s_max_elements = 20; // don't create > 20 elements
} // namespace <anonymous> } // namespace <anonymous>
struct disposer {
inline void operator()(memory_managed* ptr) const {
ptr->request_deletion();
}
};
class instance_wrapper { class instance_wrapper {
public: public:
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#ifndef CAF_FWD_HPP #ifndef CAF_FWD_HPP
#define CAF_FWD_HPP #define CAF_FWD_HPP
#include <memory>
#include <cstdint> #include <cstdint>
namespace caf { namespace caf {
...@@ -45,6 +46,7 @@ class execution_unit; ...@@ -45,6 +46,7 @@ class execution_unit;
class abstract_actor; class abstract_actor;
class abstract_group; class abstract_group;
class blocking_actor; class blocking_actor;
class mailbox_element;
class message_handler; class message_handler;
class uniform_type_info; class uniform_type_info;
class event_based_actor; class event_based_actor;
...@@ -90,6 +92,7 @@ namespace scheduler { ...@@ -90,6 +92,7 @@ namespace scheduler {
namespace detail { namespace detail {
class logging; class logging;
class disposer;
class singletons; class singletons;
class message_data; class message_data;
class group_manager; class group_manager;
...@@ -97,6 +100,8 @@ namespace detail { ...@@ -97,6 +100,8 @@ namespace detail {
class uniform_type_info_map; class uniform_type_info_map;
} // namespace detail } // namespace detail
using mailbox_element_ptr = std::unique_ptr<mailbox_element, detail::disposer>;
} // namespace caf } // namespace caf
#endif // CAF_FWD_HPP #endif // CAF_FWD_HPP
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "caf/mixin/memory_cached.hpp" #include "caf/mixin/memory_cached.hpp"
#include "caf/detail/logging.hpp" #include "caf/detail/logging.hpp"
#include "caf/detail/disposer.hpp"
#include "caf/detail/behavior_stack.hpp" #include "caf/detail/behavior_stack.hpp"
#include "caf/detail/typed_actor_util.hpp" #include "caf/detail/typed_actor_util.hpp"
#include "caf/detail/single_reader_queue.hpp" #include "caf/detail/single_reader_queue.hpp"
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include "caf/mixin/memory_cached.hpp" #include "caf/mixin/memory_cached.hpp"
#include "caf/detail/disposer.hpp"
namespace caf { namespace caf {
class mailbox_element : public extend<memory_managed>:: class mailbox_element : public extend<memory_managed>::
......
...@@ -22,10 +22,6 @@ ...@@ -22,10 +22,6 @@
namespace caf { namespace caf {
namespace detail {
struct disposer;
}
/** /**
* This base enables derived classes to enforce a different * This base enables derived classes to enforce a different
* allocation strategy than new/delete by providing a virtual * allocation strategy than new/delete by providing a virtual
...@@ -33,8 +29,6 @@ struct disposer; ...@@ -33,8 +29,6 @@ struct disposer;
*/ */
class memory_managed { class memory_managed {
public: public:
friend struct detail::disposer;
/** /**
* Default implementations calls `delete this, but can * Default implementations calls `delete this, but can
* be overriden in case deletion depends on some condition or * be overriden in case deletion depends on some condition or
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "caf/mixin/memory_cached.hpp" #include "caf/mixin/memory_cached.hpp"
#include "caf/detail/memory.hpp" #include "caf/detail/memory.hpp"
#include "caf/detail/disposer.hpp"
namespace boost { namespace boost {
namespace asio { namespace asio {
......
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