Commit 484ad007 authored by neverlord's avatar neverlord

bugfix

parent 6048c9b8
...@@ -110,9 +110,10 @@ void abstract_event_based_actor::resume(util::fiber*, scheduler::callback* cb) ...@@ -110,9 +110,10 @@ void abstract_event_based_actor::resume(util::fiber*, scheduler::callback* cb)
self.set(this); self.set(this);
try try
{ {
std::unique_ptr<detail::recursive_queue_node> e;
for (;;) for (;;)
{ {
std::unique_ptr<detail::recursive_queue_node> e{m_mailbox.try_pop()}; e.reset(m_mailbox.try_pop());
if (!e) if (!e)
{ {
m_state.store(abstract_scheduled_actor::about_to_block); m_state.store(abstract_scheduled_actor::about_to_block);
...@@ -151,7 +152,7 @@ void abstract_event_based_actor::resume(util::fiber*, scheduler::callback* cb) ...@@ -151,7 +152,7 @@ void abstract_event_based_actor::resume(util::fiber*, scheduler::callback* cb)
} }
// try to match cached messages before receiving new ones // try to match cached messages before receiving new ones
auto i = m_cache.begin(); auto i = m_cache.begin();
while (i != m_cache.end() && !m_loop_stack.empty()) while (i != m_cache.end())
{ {
switch (handle_message(*(*i))) switch (handle_message(*(*i)))
{ {
...@@ -179,6 +180,7 @@ void abstract_event_based_actor::resume(util::fiber*, scheduler::callback* cb) ...@@ -179,6 +180,7 @@ void abstract_event_based_actor::resume(util::fiber*, scheduler::callback* cb)
default: exit(7); // illegal state default: exit(7); // illegal state
} }
} }
break;
} }
case cache_msg: case cache_msg:
{ {
......
...@@ -91,16 +91,17 @@ void yielding_actor::dequeue(partial_function& fun) ...@@ -91,16 +91,17 @@ void yielding_actor::dequeue(partial_function& fun)
{ {
if (m_invoke.invoke_from_cache(fun) == false) if (m_invoke.invoke_from_cache(fun) == false)
{ {
for (;;) queue_node_ptr e;
do
{ {
queue_node_ptr e{m_mailbox.try_pop()}; e.reset(m_mailbox.try_pop());
while (!e) while (!e)
{ {
yield_until_not_empty(); yield_until_not_empty();
e.reset(m_mailbox.try_pop()); e.reset(m_mailbox.try_pop());
} }
if (m_invoke.invoke(e, fun)) return;
} }
while (!m_invoke.invoke(e, fun));
} }
} }
...@@ -116,20 +117,18 @@ void yielding_actor::dequeue(behavior& bhvr) ...@@ -116,20 +117,18 @@ void yielding_actor::dequeue(behavior& bhvr)
{ {
request_timeout(bhvr.timeout()); request_timeout(bhvr.timeout());
bool timeout_occured = false; bool timeout_occured = false;
for (;;) queue_node_ptr e;
do
{ {
queue_node_ptr e{m_mailbox.try_pop()}; e.reset(m_mailbox.try_pop());
while (!e) while (!e)
{ {
yield_until_not_empty(); yield_until_not_empty();
e.reset(m_mailbox.try_pop()); e.reset(m_mailbox.try_pop());
} }
if ( m_invoke.invoke(e, fun, &bhvr, &timeout_occured)
|| timeout_occured)
{
return;
}
} }
while ( !m_invoke.invoke(e, fun, &bhvr, &timeout_occured)
&& !timeout_occured);
} }
} }
......
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