Commit 0a2ba938 authored by Dominik Charousset's avatar Dominik Charousset

maintenance

parent 949892ea
......@@ -53,6 +53,8 @@
namespace cppa {
class self_type;
/**
* @brief Implements linking and monitoring for actors.
* @tparam Base Either {@link cppa::actor actor}
......@@ -61,6 +63,8 @@ namespace cppa {
template<class Base>
class abstract_actor : public Base {
friend class self_type;
typedef std::unique_ptr<attachable> attachable_ptr;
typedef std::lock_guard<std::mutex> guard_type;
......
......@@ -66,9 +66,6 @@ class converted_thread_context
public:
// called if the converted thread finished execution
void cleanup(std::uint32_t reason = exit_reason::normal);
void quit(std::uint32_t reason); //override
void enqueue(actor* sender, any_tuple msg); //override
......
......@@ -51,14 +51,6 @@ class local_actor;
// convertible<...> enables "actor_ptr this_actor = self;"
class self_type : public convertible<self_type, actor*> {
static void set_impl(local_actor*);
static local_actor* get_unchecked_impl();
static local_actor* get_impl();
static actor* convert_impl();
self_type(const self_type&) = delete;
self_type& operator=(const self_type&) = delete;
......@@ -91,6 +83,18 @@ class self_type : public convertible<self_type, actor*> {
return get_unchecked_impl();
}
static void cleanup_fun(local_actor*);
private:
static void set_impl(local_actor*);
static local_actor* get_unchecked_impl();
static local_actor* get_impl();
static actor* convert_impl();
};
/*
......
......@@ -50,10 +50,6 @@ void converted_thread_context::quit(std::uint32_t reason) {
throw actor_exited(reason);
}
void converted_thread_context::cleanup(std::uint32_t reason) {
super::cleanup(reason);
}
void converted_thread_context::enqueue(actor* sender, any_tuple msg) {
auto node = fetch_node(sender, std::move(msg));
CPPA_REQUIRE(node->marked == false);
......
......@@ -38,12 +38,16 @@
#include "cppa/local_actor.hpp"
#include "cppa/detail/converted_thread_context.hpp"
using cppa::detail::converted_thread_context;
namespace {
void cleanup_fun(cppa::local_actor* what) {
auto ptr = dynamic_cast<converted_thread_context*>(what);
boost::thread_specific_ptr<cppa::local_actor> t_this_context(&cppa::self_type::cleanup_fun);
} // namespace <anonymous>
namespace cppa {
void self_type::cleanup_fun(cppa::local_actor* what) {
auto ptr = dynamic_cast<detail::converted_thread_context*>(what);
if (ptr) {
// make sure "unspawned" actors quit properly
ptr->cleanup(cppa::exit_reason::normal);
......@@ -51,14 +55,6 @@ void cleanup_fun(cppa::local_actor* what) {
if (what && !what->deref()) delete what;
}
boost::thread_specific_ptr<cppa::local_actor> t_this_context(cleanup_fun);
} // namespace <anonymous>
namespace cppa {
//self_type self;
void self_type::set_impl(local_actor* ptr) {
if (ptr) ptr->ref();
t_this_context.reset(ptr);
......@@ -67,7 +63,7 @@ void self_type::set_impl(local_actor* ptr) {
local_actor* self_type::get_impl() {
auto result = t_this_context.get();
if (result == nullptr) {
result = new converted_thread_context;
result = new detail::converted_thread_context;
result->ref();
get_scheduler()->register_converted_context(result);
t_this_context.reset(result);
......
......@@ -62,11 +62,11 @@ void yielding_actor::run(void* ptr_arg) {
yield(yield_state::done);
}
void yielding_actor::yield_until_not_empty() {
if (m_mailbox.can_fetch_more() == false) {
m_state.store(abstract_scheduled_actor::about_to_block);
CPPA_MEMORY_BARRIER();
std::atomic_thread_fence(std::memory_order_seq_cst);
//CPPA_MEMORY_BARRIER();
// make sure mailbox is empty
if (m_mailbox.can_fetch_more() == false) {
m_state.store(abstract_scheduled_actor::ready);
......
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