diff options
author | jar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-31 13:10:20 +0000 |
---|---|---|
committer | jar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-31 13:10:20 +0000 |
commit | 7e0e876b16395b6aa4aa6868434d18ef975e4ae0 (patch) | |
tree | 8606bab668332a5121a5a09929d5a8f65792460d /base | |
parent | 6a0ecac6e243c72e79bca203aac7def4b6687fd1 (diff) | |
download | chromium_src-7e0e876b16395b6aa4aa6868434d18ef975e4ae0.zip chromium_src-7e0e876b16395b6aa4aa6868434d18ef975e4ae0.tar.gz chromium_src-7e0e876b16395b6aa4aa6868434d18ef975e4ae0.tar.bz2 |
Support RanAllPending() rather than RunOnce(), and integrated into ipc_sync_channel.
RunOnce() semantics were not sufficient to support the effort to pump messages
in ipc_sync_channel, as ipc_sync_channel is not able to detect pending Tasks.
This change list switches to RunAllPending() tasks, rather than just Running the items
that avail themselves in one run of the loop. This is a very small mod of the existing code.
I'm still trying to stay focused on the bug at hand, and minimize chances of
unrelated regressions (we only modify IPC channel semantics).
The slight semantic change (from original attempts to call Quit() externally and
then Run()) is that we now terminate the message loop after also servicing the
high-resolution timer tasks.
bug=1291034
r=darin
M base/message_loop.h
M base/message_loop.cc
M chrome/common/ipc_sync_channel.cc
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/message_loop.cc | 22 | ||||
-rw-r--r-- | base/message_loop.h | 13 |
2 files changed, 19 insertions, 16 deletions
diff --git a/base/message_loop.cc b/base/message_loop.cc index d348908..1fa1b29 100644 --- a/base/message_loop.cc +++ b/base/message_loop.cc @@ -176,7 +176,7 @@ void MessageLoop::Run(Dispatcher* dispatcher) { RunHandler(dispatcher, false); } -void MessageLoop::RunOnce() { +void MessageLoop::RunAllPending() { RunHandler(NULL, true); } @@ -185,15 +185,15 @@ void MessageLoop::RunOnce() { // one that calls SetUnhandledExceptionFilter(). // enable_SEH_restoration_ = true : any unhandled exception goes to the filter // that was existed before the loop was run. -void MessageLoop::RunHandler(Dispatcher* dispatcher, bool run_loop_once) { +void MessageLoop::RunHandler(Dispatcher* dispatcher, bool non_blocking) { if (exception_restoration_) { LPTOP_LEVEL_EXCEPTION_FILTER current_filter = GetTopSEHFilter(); __try { - RunInternal(dispatcher, run_loop_once); + RunInternal(dispatcher, non_blocking); } __except(SEHFilter(current_filter)) { } } else { - RunInternal(dispatcher, run_loop_once); + RunInternal(dispatcher, non_blocking); } } @@ -210,7 +210,7 @@ void MessageLoop::RunHandler(Dispatcher* dispatcher, bool run_loop_once) { // Summary: none of the above classes is starved, and sent messages has twice // the chance of being processed (i.e., reduced service time). -void MessageLoop::RunInternal(Dispatcher* dispatcher, bool run_loop_once) { +void MessageLoop::RunInternal(Dispatcher* dispatcher, bool non_blocking) { // Preserve ability to be called recursively. ScopedStateSave save(this); // State is restored on exit. dispatcher_ = dispatcher; @@ -224,12 +224,12 @@ void MessageLoop::RunInternal(Dispatcher* dispatcher, bool run_loop_once) { // shutting down properly as some operations may depend on further event // processing. (Note: some tests may use quit_now_ to exit more swiftly, // and leave messages pending, so don't assert the above fact). - RunTraditional(run_loop_once); - DCHECK(run_loop_once || quit_received_ || quit_now_); + RunTraditional(non_blocking); + DCHECK(non_blocking || quit_received_ || quit_now_); } -void MessageLoop::RunTraditional(bool run_loop_once) { - do { +void MessageLoop::RunTraditional(bool non_blocking) { + for (;;) { // If we do any work, we may create more messages etc., and more work // may possibly be waiting in another task group. When we (for example) // ProcessNextWindowsMessage(), there is a good chance there are still more @@ -260,12 +260,12 @@ void MessageLoop::RunTraditional(bool run_loop_once) { if (ProcessNextDelayedNonNestableTask()) continue; - if (run_loop_once) + if (non_blocking) return; // We service APCs in WaitForWork, without returning. WaitForWork(); // Wait (sleep) until we have work to do again. - } while (!run_loop_once); + } } //------------------------------------------------------------------------------ diff --git a/base/message_loop.h b/base/message_loop.h index ecb7e27..1610d07 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -252,8 +252,9 @@ class MessageLoop { // Run the message loop. void Run(); - // Run just one pass through the message loop. - void RunOnce(); + // Process all pending tasks, windows messages, etc., but don't wait/sleep. + // Return as soon as all items that can be run are taken care of. + void RunAllPending(); // See description of Dispatcher for how Run uses Dispatcher. void Run(Dispatcher* dispatcher); @@ -443,16 +444,18 @@ class MessageLoop { // stacks around the running of a main message loop. // It will run the message loop in a SEH try block or not depending on the // set_SEH_restoration() flag. - void RunHandler(Dispatcher* dispatcher, bool run_loop_once); + void RunHandler(Dispatcher* dispatcher, bool non_blocking); // A surrounding stack frame around the running of the message loop that // supports all saving and restoring of state, as is needed for any/all (ugly) // recursive calls. - void RunInternal(Dispatcher* dispatcher, bool run_loop_once); + void RunInternal(Dispatcher* dispatcher, bool non_blocking); // An extended message loop (message pump) that loops mostly forever, and // processes task, signals, timers, etc. - void RunTraditional(bool run_loop_once); + // If non-blocking is set, it will return rather than wait for new things to + // arrive for processing. + void RunTraditional(bool non_blocking); //---------------------------------------------------------------------------- // A list of method wrappers with identical calling signatures (no arguments) |