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

Unified Diff: mojo/edk/system/awakable_list.cc

Issue 2060943007: Make it possible to remove an Awakable with a specific "context" from a Dispatcher. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 6 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/edk/system/awakable_list.h ('k') | mojo/edk/system/awakable_list_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/awakable_list.cc
diff --git a/mojo/edk/system/awakable_list.cc b/mojo/edk/system/awakable_list.cc
index 510b88a3551fd3c02e0727d19d2aee758cd7a49b..e419d40383a2e08be8101e05287178643fb49ef6 100644
--- a/mojo/edk/system/awakable_list.cc
+++ b/mojo/edk/system/awakable_list.cc
@@ -70,5 +70,20 @@ void AwakableList::Remove(Awakable* awakable) {
awakables_.erase(last, awakables_.end());
}
+void AwakableList::RemoveWithContext(Awakable* awakable, uint64_t context) {
+ // We allow a thread to wait on the same handle multiple times simultaneously,
+ // so we need to scan the entire list and remove all occurrences of |waiter|.
+ auto last = awakables_.end();
+ for (AwakeInfoList::iterator it = awakables_.begin(); it != last;) {
+ if (it->awakable == awakable && it->context == context) {
+ --last;
+ std::swap(*it, *last);
+ } else {
+ ++it;
+ }
+ }
+ awakables_.erase(last, awakables_.end());
+}
+
} // namespace system
} // namespace mojo
« no previous file with comments | « mojo/edk/system/awakable_list.h ('k') | mojo/edk/system/awakable_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698