Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Unified Diff: mojo/public/cpp/utility/run_loop.h

Issue 588593002: mojo: Allow basic RunLoop to be quit from a posted task. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Follow review Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/utility/lib/run_loop.cc ('k') | mojo/public/cpp/utility/tests/run_loop_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/utility/run_loop.h
diff --git a/mojo/public/cpp/utility/run_loop.h b/mojo/public/cpp/utility/run_loop.h
index cba28629bd03b0711e4a33cdf8136c4714de92dc..359208d199dcd3b29eda49dce666ea00e6aadfce 100644
--- a/mojo/public/cpp/utility/run_loop.h
+++ b/mojo/public/cpp/utility/run_loop.h
@@ -40,13 +40,13 @@ class RunLoop {
void RemoveHandler(const Handle& handle);
bool HasHandler(const Handle& handle) const;
- // Runs the loop servicing handles as they are ready. This returns when Quit()
- // is invoked, or there no more handles.
+ // Runs the loop servicing handles and tasks as they are ready. This returns
+ // when Quit() is invoked, or there are no more handles nor tasks.
void Run();
- // Runs the loop servicing any handles that are ready. Does not wait for
- // handles to become ready before returning. Returns early if Quit() is
- // invoked.
+ // Runs the loop servicing any handles and tasks that are ready. Does not wait
+ // for handles or tasks to become ready before returning. Returns early if
+ // Quit() is invoked.
void RunUntilIdle();
void Quit();
@@ -83,13 +83,25 @@ class RunLoop {
IGNORE_DEADLINE
};
- // Do one unit of delayed work, if eligible.
- void DoDelayedWork();
+ // Mode of operation of the run loop.
+ enum RunMode {
+ UNTIL_EMPTY,
+ UNTIL_IDLE
+ };
+
+ // Runs the loop servicing any handles and tasks that are ready. If
+ // |run_mode| is |UNTIL_IDLE|, does not wait for handles or tasks to become
+ // ready before returning. Returns early if Quit() is invoked.
+ void RunInternal(RunMode run_mode);
+
+ // Do one unit of delayed work, if eligible. Returns true is a task was run.
+ bool DoDelayedWork();
- // Waits for a handle to be ready. Returns after servicing at least one
- // handle (or there are no more handles) unless |non_blocking| is true,
- // in which case it will also return if servicing at least one handle
- // would require blocking. Returns true if a RunLoopHandler was notified.
+ // Waits for a handle to be ready or until the next task must be run. Returns
+ // after servicing at least one handle (or there are no more handles) unless
+ // a task must be run or |non_blocking| is true, in which case it will also
+ // return if no task is registered and servicing at least one handle would
+ // require blocking. Returns true if a RunLoopHandler was notified.
bool Wait(bool non_blocking);
// Notifies handlers of |error|. If |check| == CHECK_DEADLINE, this will
« no previous file with comments | « mojo/public/cpp/utility/lib/run_loop.cc ('k') | mojo/public/cpp/utility/tests/run_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698