Commit c1f41337 authored by neverlord's avatar neverlord

maintenance

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