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

Side by Side Diff: mojo/edk/system/awakable_list.cc

Issue 2085583006: Add more tests for AwakableList (esp. persistent vs one-shot awakables). (Closed) Base URL: https://github.com/domokit/mojo.git@work794_wait_set_4.6
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 unified diff | Download patch
« no previous file with comments | « no previous file | mojo/edk/system/awakable_list_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/edk/system/awakable_list.h" 5 #include "mojo/edk/system/awakable_list.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "mojo/edk/system/awakable.h" 10 #include "mojo/edk/system/awakable.h"
(...skipping 19 matching lines...) Expand all
30 // Persistent awakables are called for all changes on watched signals. 30 // Persistent awakables are called for all changes on watched signals.
31 if ((new_state.satisfied_signals & it->signals) != 31 if ((new_state.satisfied_signals & it->signals) !=
32 (old_state.satisfied_signals & it->signals) || 32 (old_state.satisfied_signals & it->signals) ||
33 (new_state.satisfiable_signals & it->signals) != 33 (new_state.satisfiable_signals & it->signals) !=
34 (old_state.satisfiable_signals & it->signals)) { 34 (old_state.satisfiable_signals & it->signals)) {
35 awoken = true; 35 awoken = true;
36 it->awakable->Awake(it->context, Awakable::AwakeReason::CHANGED, 36 it->awakable->Awake(it->context, Awakable::AwakeReason::CHANGED,
37 new_state); 37 new_state);
38 } 38 }
39 } else { 39 } else {
40 // One-shot awakables are only called on "leading edge" changes. 40 // One-shot awakables are only called on "leading edge" changes in overall
41 // satisfied-ness or never-satisfiable-ness. (That is, if a one-shot
42 // awakable was previously satisfied and is still satisfied, but for
43 // different reasons, it will not be called.)
41 if (new_state.satisfies(it->signals) && 44 if (new_state.satisfies(it->signals) &&
42 !old_state.satisfies(it->signals)) { 45 !old_state.satisfies(it->signals)) {
43 awoken = true; 46 awoken = true;
44 it->awakable->Awake(it->context, Awakable::AwakeReason::SATISFIED, 47 it->awakable->Awake(it->context, Awakable::AwakeReason::SATISFIED,
45 new_state); 48 new_state);
46 } else if (!new_state.can_satisfy(it->signals) && 49 } else if (!new_state.can_satisfy(it->signals) &&
47 old_state.can_satisfy(it->signals)) { 50 old_state.can_satisfy(it->signals)) {
48 awoken = true; 51 awoken = true;
49 it->awakable->Awake(it->context, Awakable::AwakeReason::UNSATISFIABLE, 52 it->awakable->Awake(it->context, Awakable::AwakeReason::UNSATISFIABLE,
50 new_state); 53 new_state);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 std::swap(*it, *last); 93 std::swap(*it, *last);
91 } else { 94 } else {
92 ++it; 95 ++it;
93 } 96 }
94 } 97 }
95 awakables_.erase(last, awakables_.end()); 98 awakables_.erase(last, awakables_.end());
96 } 99 }
97 100
98 } // namespace system 101 } // namespace system
99 } // namespace mojo 102 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/edk/system/awakable_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698