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

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

Issue 2072353002: Give AwakableList's wake-up method the old state in addition to the new state. (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 e419d40383a2e08be8101e05287178643fb49ef6..2c2b466b508a4d4829310562df3653fe1738b440 100644
--- a/mojo/edk/system/awakable_list.cc
+++ b/mojo/edk/system/awakable_list.cc
@@ -20,15 +20,17 @@ AwakableList::~AwakableList() {
DCHECK(awakables_.empty());
}
-void AwakableList::AwakeForStateChange(const HandleSignalsState& state) {
+void AwakableList::OnStateChange(const HandleSignalsState& old_state,
+ const HandleSignalsState& new_state) {
// Instead of deleting elements in-place, swap them with the last element and
// erase the elements from the end.
auto last = awakables_.end();
for (AwakeInfoList::iterator it = awakables_.begin(); it != last;) {
bool keep = true;
- if (state.satisfies(it->signals))
+ if (new_state.satisfies(it->signals) && !old_state.satisfies(it->signals))
keep = it->awakable->Awake(MOJO_RESULT_OK, it->context);
- else if (!state.can_satisfy(it->signals))
+ else if (!new_state.can_satisfy(it->signals) &&
+ old_state.can_satisfy(it->signals))
keep = it->awakable->Awake(MOJO_RESULT_FAILED_PRECONDITION, it->context);
if (!keep) {
« 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