Commit 0242637b authored by neverlord's avatar neverlord

scheduler_helper

parent 59aa1fa3
...@@ -11,6 +11,7 @@ namespace cppa { ...@@ -11,6 +11,7 @@ namespace cppa {
class context; class context;
class actor_behavior; class actor_behavior;
class scheduler_helper;
/** /**
* @brief * @brief
...@@ -18,8 +19,12 @@ class actor_behavior; ...@@ -18,8 +19,12 @@ class actor_behavior;
class scheduler class scheduler
{ {
scheduler_helper* m_helper;
protected: protected:
scheduler();
/** /**
* @brief Calls {@link context::exit(std::uint32_t) context::exit}. * @brief Calls {@link context::exit(std::uint32_t) context::exit}.
*/ */
......
...@@ -8,8 +8,9 @@ ...@@ -8,8 +8,9 @@
#include "cppa/context.hpp" #include "cppa/context.hpp"
#include "cppa/scheduler.hpp" #include "cppa/scheduler.hpp"
#include "cppa/detail/actor_count.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/thread_pool_scheduler.hpp"
#include "cppa/detail/converted_thread_context.hpp"
namespace { namespace {
...@@ -38,8 +39,40 @@ s_cleanup_helper; ...@@ -38,8 +39,40 @@ s_cleanup_helper;
namespace cppa { 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() scheduler::~scheduler()
{ {
delete m_helper;
} }
void scheduler::await_others_done() 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