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

Unified Diff: mojo/edk/system/watcher_dispatcher.h

Issue 2754083003: Mojo EDK: Circulate MojoArmWatcher outputs to avoid starvation (Closed)
Patch Set: . Created 3 years, 9 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 | « no previous file | mojo/edk/system/watcher_dispatcher.cc » ('j') | mojo/edk/system/watcher_dispatcher.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/watcher_dispatcher.h
diff --git a/mojo/edk/system/watcher_dispatcher.h b/mojo/edk/system/watcher_dispatcher.h
index 9698818272ea68ca319dd912e55acf4573eac991..605a3150cc1acea51382d5ee6023503492e3f95a 100644
--- a/mojo/edk/system/watcher_dispatcher.h
+++ b/mojo/edk/system/watcher_dispatcher.h
@@ -55,6 +55,8 @@ class WatcherDispatcher : public Dispatcher {
private:
friend class Watch;
+ using WatchSet = std::set<const Watch*>;
+
~WatcherDispatcher() override;
const MojoWatcherCallback callback_;
@@ -80,7 +82,15 @@ class WatcherDispatcher : public Dispatcher {
// used for efficient arming behavior, as it allows for O(1) discovery of
// whether or not arming can succeed and quick determination of who's
// responsible if it can't.
- std::set<Watch*> ready_watches_;
+ WatchSet ready_watches_;
+
+ // Tracks the last Watch whose state was returned by Arm(). This is used to
+ // ensure consistent round-robin behavior in the event that multiple Watches
+ // remain ready over the span of several Arm() attempts.
+ //
+ // NOTE: This pointer is only used to index |ready_watches_| and may point to
+ // an invalid object. It must therefore never be dereferenced.
+ const Watch* last_watch_to_block_arming_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(WatcherDispatcher);
};
« no previous file with comments | « no previous file | mojo/edk/system/watcher_dispatcher.cc » ('j') | mojo/edk/system/watcher_dispatcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698