Commit c1f41337 authored by neverlord's avatar neverlord

maintenance

parent c05a8c82
...@@ -176,7 +176,8 @@ class abstract_actor : public Base ...@@ -176,7 +176,8 @@ class abstract_actor : public Base
guard_type guard(m_mtx); guard_type guard(m_mtx);
if (exited()) if (exited())
{ {
other->enqueue(this, atom(":Exit"), m_exit_reason.load()); other->enqueue(this, make_tuple(atom(":Exit"),
m_exit_reason.load()));
} }
else if (other->establish_backlink(this)) else if (other->establish_backlink(this))
{ {
......
...@@ -44,19 +44,14 @@ enum class yield_state ...@@ -44,19 +44,14 @@ enum class yield_state
// actor waits for messages // actor waits for messages
blocked, blocked,
// actor finished execution // actor finished execution
done, done
// actor was killed because of an unhandled exception
killed
}; };
// return to the scheduler / worker // return to the scheduler / worker
void yield(yield_state); void yield(yield_state);
// returns the yielded state of a scheduled actor
yield_state yielded_state();
// switches to @p what and returns to @p from after yield(...) // switches to @p what and returns to @p from after yield(...)
void call(util::fiber* what, util::fiber* from); yield_state call(util::fiber* what, util::fiber* from);
} } // namespace cppa::detail } } // namespace cppa::detail
......
...@@ -50,17 +50,13 @@ void yield(yield_state ystate) ...@@ -50,17 +50,13 @@ void yield(yield_state ystate)
util::fiber::swap(*t_callee, *t_caller); util::fiber::swap(*t_callee, *t_caller);
} }
yield_state yielded_state() yield_state call(util::fiber* what, util::fiber* from)
{
return t_ystate;
}
void call(util::fiber* what, util::fiber* from)
{ {
t_ystate = yield_state::invalid; t_ystate = yield_state::invalid;
t_caller = from; t_caller = from;
t_callee = what; t_callee = what;
util::fiber::swap(*from, *what); util::fiber::swap(*from, *what);
return t_ystate;
} }
} } // namespace cppa::detail } } // namespace cppa::detail
...@@ -136,11 +136,9 @@ void yielding_actor::resume(util::fiber* from, resume_callback* callback) ...@@ -136,11 +136,9 @@ void yielding_actor::resume(util::fiber* from, resume_callback* callback)
//set_self(this); //set_self(this);
for (;;) for (;;)
{ {
call(&m_fiber, from); switch (call(&m_fiber, from))
switch (yielded_state())
{ {
case yield_state::done: case yield_state::done:
case yield_state::killed:
{ {
callback->exec_done(); callback->exec_done();
return; return;
......
...@@ -61,17 +61,18 @@ size_t test__yield_interface() ...@@ -61,17 +61,18 @@ size_t test__yield_interface()
fiber fself; fiber fself;
fiber fcoroutine(coroutine, &worker); fiber fcoroutine(coroutine, &worker);
yield_state ys;
int i = 0; int i = 0;
do do
{ {
if (i == 2) worker.m_blocked = false; if (i == 2) worker.m_blocked = false;
call(&fcoroutine, &fself); ys = call(&fcoroutine, &fself);
++i; ++i;
} }
while (yielded_state() != yield_state::done && i < 12); while (ys != yield_state::done && i < 12);
CPPA_CHECK_EQUAL(yielded_state(), yield_state::done); CPPA_CHECK_EQUAL(ys, yield_state::done);
CPPA_CHECK_EQUAL(worker.m_count, 10); CPPA_CHECK_EQUAL(worker.m_count, 10);
CPPA_CHECK_EQUAL(i, 12); CPPA_CHECK_EQUAL(i, 12);
......
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