Implement support for coroutines in C++

This commit is contained in:
Eduardo Bart
2012-08-04 01:46:04 -03:00
parent 6a68569319
commit fa15c25951
3 changed files with 121 additions and 0 deletions

View File

@@ -75,6 +75,16 @@ void EventDispatcher::poll()
}
m_pollEventsSize = m_eventList.size();
}
for(auto it = m_coroutines.begin(); it != m_coroutines.end();) {
stdext::coroutine& coroutine = (*it);
if(coroutine.is_finished())
it = m_coroutines.erase(it);
else {
coroutine.resume();
++it;
}
}
}
ScheduledEventPtr EventDispatcher::scheduleEvent(const std::function<void()>& callback, int delay)
@@ -114,3 +124,8 @@ EventPtr EventDispatcher::addEvent(const std::function<void()>& callback, bool p
m_eventList.push_back(event);
return event;
}
void EventDispatcher::addCoroutine(const stdext::coroutine& coroutine)
{
m_coroutines.push_back(coroutine);
}