Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Scheduler::RunLoop() {
- while (!run_queue_.IsEmpty() || !sleep_queue_.IsEmpty()) {
- Fiber* next = nullptr;
- while (!sleep_queue_.IsEmpty() && (next = sleep_queue_.TryPop())) {
- next->SetState(FiberState::Runnable);
- run_queue_.PushBack(next);
- }
- if (!run_queue_.IsEmpty()) {
- next = run_queue_.PopFront();
- SwitchTo(next);
- Reschedule(next);
- } else if (!sleep_queue_.IsEmpty()){
- sleep_queue_.Sleep();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement