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

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
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..0ecc8297603b5237510f5bfbf614d5de7b177435 100644
--- a/mojo/public/cpp/utility/run_loop.h
+++ b/mojo/public/cpp/utility/run_loop.h
@@ -40,12 +40,12 @@ 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
+ // Runs the loop servicing any handles and tasks that are ready. Does not wait
+ // for handles to become ready before returning. Returns early if Quit() is
// invoked.
void RunUntilIdle();
@@ -83,13 +83,19 @@ class RunLoop {
IGNORE_DEADLINE
};
+ // Runs the loop servicing any handles that are ready. If |until_idle| is
+ // true, does not wait for handles to become ready before returning. Returns
+ // early if Quit() is invoked.
+ void RunInternal(bool until_idle);
+
// Do one unit of delayed work, if eligible.
void 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

Powered by Google App Engine
This is Rietveld 408576698