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

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

Issue 2088833003: Add different behavior to AwakableList for "persistent" vs "one-shot" awakables. (Closed) Base URL: https://github.com/domokit/mojo.git@work793_wait_set_4.5
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 | « mojo/edk/system/waiter.h ('k') | no next file » | 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/waiter.h" 5 #include "mojo/edk/system/waiter.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/edk/platform/time_ticks.h" 8 #include "mojo/edk/platform/time_ticks.h"
9 9
10 using mojo::platform::GetTimeTicks; 10 using mojo::platform::GetTimeTicks;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 } 86 }
87 87
88 if (context) 88 if (context)
89 *context = awake_context_; 89 *context = awake_context_;
90 if (signals_state) 90 if (signals_state)
91 *signals_state = signals_state_; 91 *signals_state = signals_state_;
92 return MojoResultForAwakeReason(awake_reason_); 92 return MojoResultForAwakeReason(awake_reason_);
93 } 93 }
94 94
95 bool Waiter::Awake(uint64_t context, 95 void Waiter::Awake(uint64_t context,
96 AwakeReason reason, 96 AwakeReason reason,
97 const HandleSignalsState& signals_state) { 97 const HandleSignalsState& signals_state) {
98 MutexLocker locker(&mutex_); 98 MutexLocker locker(&mutex_);
99 99
100 if (awoken_) 100 if (awoken_)
101 return true; 101 return;
102 102
103 awoken_ = true; 103 awoken_ = true;
104 awake_reason_ = reason; 104 awake_reason_ = reason;
105 signals_state_ = signals_state; 105 signals_state_ = signals_state;
106 awake_context_ = context; 106 awake_context_ = context;
107 cv_.Signal(); 107 cv_.Signal();
108 // |cv_.Wait()|/|cv_.WaitWithTimeout()| will return after |mutex_| is 108 // |cv_.Wait()|/|cv_.WaitWithTimeout()| will return after |mutex_| is
109 // released. 109 // released.
110 return true;
111 } 110 }
112 111
113 } // namespace system 112 } // namespace system
114 } // namespace mojo 113 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/waiter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698