Created
December 30, 2011 13:57
-
-
Save huangdongxu/1539971 to your computer and use it in GitHub Desktop.
messageloop_dowork.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool MessageLoop::DoWork() { | |
if (!nestable_tasks_allowed_) { | |
// Task can't be executed right now. | |
return false; | |
} | |
for (;;) { | |
ReloadWorkQueue(); | |
if (work_queue_.empty()) | |
break; | |
// Execute oldest task. | |
do { | |
PendingTask pending_task = work_queue_.front(); | |
work_queue_.pop(); | |
if (!pending_task.delayed_run_time.is_null()) { | |
AddToDelayedWorkQueue(pending_task); | |
// If we changed the topmost task, then it is time to reschedule. | |
if (delayed_work_queue_.top().task.Equals(pending_task.task)) | |
pump_->ScheduleDelayedWork(pending_task.delayed_run_time); | |
} else { | |
if (DeferOrRunPendingTask(pending_task)) | |
return true; | |
} | |
} while (!work_queue_.empty()); | |
} | |
// Nothing happened. | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment