Commit ade02937 authored by Dominik Charousset's avatar Dominik Charousset

Move `detail::disposer` to its own header

parent 963a0bc8
......@@ -29,7 +29,7 @@
#include "caf/mixin/sync_sender.hpp"
#include "caf/mixin/behavior_stack_based.hpp"
#include "caf/detail/memory.hpp"
#include "caf/detail/disposer.hpp"
#include "caf/detail/shared_spinlock.hpp"
namespace caf {
......@@ -39,16 +39,13 @@ namespace caf {
* callback to another object, thus serving as gateway to
* allow any object to interact with other actors.
*/
class actor_companion : public extend<local_actor, actor_companion>::
with<mixin::behavior_stack_based<behavior>::impl,
mixin::sync_sender<nonblocking_response_handle_tag>::impl> {
using lock_type = detail::shared_spinlock;
class actor_companion
: public extend<local_actor, actor_companion>::
with<mixin::behavior_stack_based<behavior>::impl,
mixin::sync_sender<nonblocking_response_handle_tag>::impl> {
public:
using lock_type = detail::shared_spinlock;
using message_pointer = std::unique_ptr<mailbox_element, detail::disposer>;
using enqueue_handler = std::function<void (message_pointer)>;
/**
......@@ -64,16 +61,14 @@ class actor_companion : public extend<local_actor, actor_companion>::
void on_enqueue(enqueue_handler handler);
void enqueue(const actor_addr& sender, message_id mid,
message content, execution_unit* host) override;
message content, execution_unit* host) override;
private:
// set by parent to define custom enqueue action
enqueue_handler m_on_enqueue;
// guards access to m_handler
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
} // namespace <anonymous>
struct disposer {
inline void operator()(memory_managed* ptr) const {
ptr->request_deletion();
}
};
class instance_wrapper {
public:
......
......@@ -20,6 +20,7 @@
#ifndef CAF_FWD_HPP
#define CAF_FWD_HPP
#include <memory>
#include <cstdint>
namespace caf {
......@@ -45,6 +46,7 @@ class execution_unit;
class abstract_actor;
class abstract_group;
class blocking_actor;
class mailbox_element;
class message_handler;
class uniform_type_info;
class event_based_actor;
......@@ -90,6 +92,7 @@ namespace scheduler {
namespace detail {
class logging;
class disposer;
class singletons;
class message_data;
class group_manager;
......@@ -97,6 +100,8 @@ namespace detail {
class uniform_type_info_map;
} // namespace detail
using mailbox_element_ptr = std::unique_ptr<mailbox_element, detail::disposer>;
} // namespace caf
#endif // CAF_FWD_HPP
......@@ -49,6 +49,7 @@
#include "caf/mixin/memory_cached.hpp"
#include "caf/detail/logging.hpp"
#include "caf/detail/disposer.hpp"
#include "caf/detail/behavior_stack.hpp"
#include "caf/detail/typed_actor_util.hpp"
#include "caf/detail/single_reader_queue.hpp"
......
......@@ -30,6 +30,8 @@
#include "caf/mixin/memory_cached.hpp"
#include "caf/detail/disposer.hpp"
namespace caf {
class mailbox_element : public extend<memory_managed>::
......
......@@ -22,10 +22,6 @@
namespace caf {
namespace detail {
struct disposer;
}
/**
* This base enables derived classes to enforce a different
* allocation strategy than new/delete by providing a virtual
......@@ -33,8 +29,6 @@ struct disposer;
*/
class memory_managed {
public:
friend struct detail::disposer;
/**
* Default implementations calls `delete this, but can
* be overriden in case deletion depends on some condition or
......
......@@ -37,6 +37,7 @@
#include "caf/mixin/memory_cached.hpp"
#include "caf/detail/memory.hpp"
#include "caf/detail/disposer.hpp"
namespace boost {
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