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

Side by Side Diff: mojo/edk/system/local_message_pipe_endpoint.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 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE; 143 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE;
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,
154 bool force,
153 MojoHandleSignals signals, 155 MojoHandleSignals signals,
154 bool force,
155 uint64_t context,
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 (force)
164 awakable_list_.Add(awakable, signals, context); 164 awakable_list_.Add(awakable, context, 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)
169 awakable_list_.Add(awakable, context, signals);
168 return MOJO_RESULT_FAILED_PRECONDITION; 170 return MOJO_RESULT_FAILED_PRECONDITION;
171 }
169 172
170 awakable_list_.Add(awakable, signals, context); 173 awakable_list_.Add(awakable, context, signals);
171 return MOJO_RESULT_OK; 174 return MOJO_RESULT_OK;
172 } 175 }
173 176
174 void LocalMessagePipeEndpoint::RemoveAwakable( 177 void LocalMessagePipeEndpoint::RemoveAwakable(
175 Awakable* awakable, 178 bool match_context,
176 HandleSignalsState* signals_state) {
177 DCHECK(is_open_);
178 awakable_list_.Remove(awakable);
179 if (signals_state)
180 *signals_state = GetHandleSignalsState();
181 }
182
183 void LocalMessagePipeEndpoint::RemoveAwakableWithContext(
184 Awakable* awakable, 179 Awakable* awakable,
185 uint64_t context, 180 uint64_t context,
186 HandleSignalsState* signals_state) { 181 HandleSignalsState* signals_state) {
187 DCHECK(is_open_); 182 DCHECK(is_open_);
188 awakable_list_.RemoveWithContext(awakable, context); 183 awakable_list_.Remove(match_context, awakable, context);
189 if (signals_state) 184 if (signals_state)
190 *signals_state = GetHandleSignalsState(); 185 *signals_state = GetHandleSignalsState();
191 } 186 }
192 187
193 } // namespace system 188 } // namespace system
194 } // 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