mirror of
https://github.com/edubart/otclient.git
synced 2025-12-23 00:27:12 +01:00
Implement support for coroutines in C++
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user