schedule coroutine to timer while waiting for IO

This commit is contained in:
lganzzzo 2019-04-16 03:49:11 +03:00
parent 61276f9c89
commit 252a25a431
3 changed files with 19 additions and 10 deletions

View File

@ -80,11 +80,6 @@ void IOWorker::work() {
switch(action.getType()) {
case Action::TYPE_IO_WAIT:
roundIteration = 0;
m_queue.round();
break;
case Action::TYPE_IO_REPEAT:
++ roundIteration;
if(roundIteration == 10) {
@ -93,6 +88,20 @@ void IOWorker::work() {
}
break;
// case Action::TYPE_IO_WAIT:
// roundIteration = 0;
// m_queue.popFront();
// setCoroutineScheduledAction(CP, std::move(action));
// getCoroutineProcessor(CP)->pushOneTaskFromIO(CP);
// break;
case Action::TYPE_IO_WAIT: // schedule for timer
roundIteration = 0;
m_queue.popFront();
setCoroutineScheduledAction(CP, oatpp::async::Action::createWaitRepeatAction(0));
getCoroutineProcessor(CP)->pushOneTaskFromIO(CP);
break;
default:
roundIteration = 0;
m_queue.popFront();

View File

@ -76,12 +76,12 @@ void Processor::addCoroutine(AbstractCoroutine* coroutine) {
switch(action.m_type) {
case Action::TYPE_IO_WAIT:
case Action::TYPE_IO_REPEAT:
coroutine->_SCH_A = Action::clone(action);
popIOTask(coroutine);
break;
case Action::TYPE_IO_REPEAT:
case Action::TYPE_IO_WAIT:
coroutine->_SCH_A = Action::clone(action);
popIOTask(coroutine);
break;

View File

@ -81,9 +81,9 @@ void TimerWorker::work() {
setCoroutineScheduledAction(curr, std::move(action));
break;
// case Action::TYPE_IO_WAIT:
// setCoroutineScheduledAction(curr, oatpp::async::Action::createWaitRepeatAction(0));
// break;
case Action::TYPE_IO_WAIT:
setCoroutineScheduledAction(curr, oatpp::async::Action::createWaitRepeatAction(0));
break;
default:
m_queue.cutEntry(curr, prev);