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

Side by Side Diff: mojo/edk/system/local_message_pipe_endpoint.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/local_message_pipe_endpoint.h ('k') | mojo/edk/system/message_pipe.h » ('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/local_message_pipe_endpoint.h" 5 #include "mojo/edk/system/local_message_pipe_endpoint.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 void LocalMessagePipeEndpoint::Close() { 60 void LocalMessagePipeEndpoint::Close() {
61 DCHECK(is_open_); 61 DCHECK(is_open_);
62 is_open_ = false; 62 is_open_ = false;
63 message_queue_.Clear(); 63 message_queue_.Clear();
64 } 64 }
65 65
66 void LocalMessagePipeEndpoint::CancelAllState() { 66 void LocalMessagePipeEndpoint::CancelAllState() {
67 DCHECK(is_open_); 67 DCHECK(is_open_);
68 awakable_list_.CancelAll(); 68 awakable_list_.CancelAndRemoveAll();
69 } 69 }
70 70
71 MojoResult LocalMessagePipeEndpoint::ReadMessage( 71 MojoResult LocalMessagePipeEndpoint::ReadMessage(
72 UserPointer<void> bytes, 72 UserPointer<void> bytes,
73 UserPointer<uint32_t> num_bytes, 73 UserPointer<uint32_t> num_bytes,
74 HandleVector* handles, 74 HandleVector* handles,
75 uint32_t* num_handles, 75 uint32_t* num_handles,
76 MojoReadMessageFlags flags) { 76 MojoReadMessageFlags flags) {
77 DCHECK(is_open_); 77 DCHECK(is_open_);
78 DCHECK(!handles || handles->empty()); 78 DCHECK(!handles || handles->empty());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } else { 144 } else {
145 rv.satisfied_signals |= MOJO_HANDLE_SIGNAL_PEER_CLOSED; 145 rv.satisfied_signals |= MOJO_HANDLE_SIGNAL_PEER_CLOSED;
146 } 146 }
147 rv.satisfiable_signals |= MOJO_HANDLE_SIGNAL_PEER_CLOSED; 147 rv.satisfiable_signals |= MOJO_HANDLE_SIGNAL_PEER_CLOSED;
148 return rv; 148 return rv;
149 } 149 }
150 150
151 MojoResult LocalMessagePipeEndpoint::AddAwakable( 151 MojoResult LocalMessagePipeEndpoint::AddAwakable(
152 Awakable* awakable, 152 Awakable* awakable,
153 uint64_t context, 153 uint64_t context,
154 bool force, 154 bool persistent,
155 MojoHandleSignals signals, 155 MojoHandleSignals signals,
156 HandleSignalsState* signals_state) { 156 HandleSignalsState* signals_state) {
157 DCHECK(is_open_); 157 DCHECK(is_open_);
158 158
159 HandleSignalsState state = GetHandleSignalsState(); 159 HandleSignalsState state = GetHandleSignalsState();
160 if (signals_state) 160 if (signals_state)
161 *signals_state = state; 161 *signals_state = state;
162 if (state.satisfies(signals)) { 162 if (state.satisfies(signals)) {
163 if (force) 163 if (persistent)
164 awakable_list_.Add(awakable, context, signals); 164 awakable_list_.Add(awakable, context, persistent, signals);
165 return MOJO_RESULT_ALREADY_EXISTS; 165 return MOJO_RESULT_ALREADY_EXISTS;
166 } 166 }
167 if (!state.can_satisfy(signals)) { 167 if (!state.can_satisfy(signals)) {
168 if (force) 168 if (persistent)
169 awakable_list_.Add(awakable, context, signals); 169 awakable_list_.Add(awakable, context, persistent, signals);
170 return MOJO_RESULT_FAILED_PRECONDITION; 170 return MOJO_RESULT_FAILED_PRECONDITION;
171 } 171 }
172 172
173 awakable_list_.Add(awakable, context, signals); 173 awakable_list_.Add(awakable, context, persistent, signals);
174 return MOJO_RESULT_OK; 174 return MOJO_RESULT_OK;
175 } 175 }
176 176
177 void LocalMessagePipeEndpoint::RemoveAwakable( 177 void LocalMessagePipeEndpoint::RemoveAwakable(
178 bool match_context, 178 bool match_context,
179 Awakable* awakable, 179 Awakable* awakable,
180 uint64_t context, 180 uint64_t context,
181 HandleSignalsState* signals_state) { 181 HandleSignalsState* signals_state) {
182 DCHECK(is_open_); 182 DCHECK(is_open_);
183 awakable_list_.Remove(match_context, awakable, context); 183 awakable_list_.Remove(match_context, awakable, context);
184 if (signals_state) 184 if (signals_state)
185 *signals_state = GetHandleSignalsState(); 185 *signals_state = GetHandleSignalsState();
186 } 186 }
187 187
188 } // namespace system 188 } // namespace system
189 } // namespace mojo 189 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/local_message_pipe_endpoint.h ('k') | mojo/edk/system/message_pipe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698