| 482 | } |
| 483 | |
| 484 | void itask_yield(Tick delay, s32 ip) |
| 485 | { |
| 486 | // This is caused by a bug in a mod. |
| 487 | // TODO: Figure out the root cause. |
| 488 | if (s_curContext != &s_curTask->context) |
| 489 | { |
| 490 | s_curContext = &s_curTask->context; |
| 491 | } |
| 492 | |
| 493 | // Copy the ip so we know where to return. |
| 494 | assert(s_curContext->level >= 0 && s_curContext->level < TASK_MAX_LEVELS); |
| 495 | s_curContext->ip[s_curContext->level] = ip; |
| 496 | s_curContext->level--; |
| 497 | |
| 498 | TASK_MSG("Task yield: '%s' for %u ticks", s_curTask->name, delay); |
| 499 | |
| 500 | // If there is a return task, then take it next. |
| 501 | if (s_curTask->retTask) |
| 502 | { |
| 503 | // Clear out the return task once it is executed. |
| 504 | Task* retTask = s_curTask->retTask; |
| 505 | s_curTask->retTask = nullptr; |
| 506 | |
| 507 | // Set the next task. |
| 508 | s_currentMsg = MSG_RUN_TASK; |
| 509 | s_curTask = retTask; |
| 510 | s_curContext = &s_curTask->context; |
| 511 | |
| 512 | TASK_MSG("Return Task: '%s'", s_curTask->name); |
| 513 | return; |
| 514 | } |
| 515 | |
| 516 | // Update the current tick based on the delay. |
| 517 | s_curTask->nextTick = (delay < TASK_SLEEP) ? s_curTick + delay : delay; |
| 518 | |
| 519 | // Find the next task to run. |
| 520 | selectNextTask(); |
| 521 | assert(s_curTask); |
| 522 | TASK_MSG("Task Selected: '%s'", s_curTask->name); |
| 523 | } |
| 524 | |
| 525 | void task_setMinStepInterval(f64 minIntervalInSec) |
| 526 | { |
nothing calls this directly
no test coverage detected