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

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

Issue 2084593005: Rationalize AddAwakable...() and RemoveAwakable...() methods. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: doh 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 b3e2763823ef811b2d58aba986649e8118e5270c..fb432b91dc67dc087e34d82a9cab792558402277 100644
--- a/mojo/edk/system/awakable_list.cc
+++ b/mojo/edk/system/awakable_list.cc
@@ -55,32 +55,20 @@ void AwakableList::CancelAll() {
}
void AwakableList::Add(Awakable* awakable,
- MojoHandleSignals signals,
- uint64_t context) {
+ uint64_t context,
+ MojoHandleSignals signals) {
awakables_.push_back(AwakeInfo(awakable, signals, context));
}
-void AwakableList::Remove(Awakable* awakable) {
+void AwakableList::Remove(bool match_context,
+ 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) {
- --last;
- std::swap(*it, *last);
- } else {
- ++it;
- }
- }
- 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) {
+ if (it->awakable == awakable &&
+ (!match_context || it->context == context)) {
--last;
std::swap(*it, *last);
} else {
« 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