Commit 0242637b authored by neverlord's avatar neverlord

scheduler_helper

parent 59aa1fa3
......@@ -11,6 +11,7 @@ namespace cppa {
class context;
class actor_behavior;
class scheduler_helper;
/**
* @brief
......@@ -18,8 +19,12 @@ class actor_behavior;
class scheduler
{
scheduler_helper* m_helper;
protected:
scheduler();
/**
* @brief Calls {@link context::exit(std::uint32_t) context::exit}.
*/
......
......@@ -8,8 +8,9 @@
#include "cppa/context.hpp"
#include "cppa/scheduler.hpp"
#include "cppa/detail/actor_count.hpp"
//#include "cppa/detail/mock_scheduler.hpp"
#include "cppa/detail/mock_scheduler.hpp"
#include "cppa/detail/thread_pool_scheduler.hpp"
#include "cppa/detail/converted_thread_context.hpp"
namespace {
......@@ -38,8 +39,40 @@ s_cleanup_helper;
namespace cppa {
class scheduler_helper
{
cppa::intrusive_ptr<cppa::context> m_worker;
static void worker_loop(cppa::intrusive_ptr<cppa::context> m_self);
public:
scheduler_helper() : m_worker(new detail::converted_thread_context)
{
// do NOT increase actor count; worker is "invisible"
boost::thread(&scheduler_helper::worker_loop, m_worker).detach();
}
~scheduler_helper()
{
m_worker->enqueue(message(m_worker, m_worker, atom(":_DIE")));
}
};
void scheduler_helper::worker_loop(cppa::intrusive_ptr<cppa::context> m_self)
{
set_self(m_self.get());
}
scheduler::scheduler() : m_helper(new scheduler_helper)
{
}
scheduler::~scheduler()
{
delete m_helper;
}
void scheduler::await_others_done()
......
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