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

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

Issue 2090763002: AwakableList: For persistent awakables, make Add() call Awake() with reason INITIALIZE. (Closed) Base URL: https://github.com/domokit/mojo.git@work795_wait_set_4.7-x-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 | « mojo/edk/system/data_pipe.cc ('k') | mojo/edk/system/simple_dispatcher.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/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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 Awakable* awakable, 152 Awakable* awakable,
153 uint64_t context, 153 uint64_t context,
154 bool persistent, 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 MojoResult rv = MOJO_RESULT_OK;
163 if (persistent) 163 bool should_add = persistent;
164 awakable_list_.Add(awakable, context, persistent, signals); 164 if (state.satisfies(signals))
165 return MOJO_RESULT_ALREADY_EXISTS; 165 rv = MOJO_RESULT_ALREADY_EXISTS;
166 } 166 else if (!state.can_satisfy(signals))
167 if (!state.can_satisfy(signals)) { 167 rv = MOJO_RESULT_FAILED_PRECONDITION;
168 if (persistent) 168 else
169 awakable_list_.Add(awakable, context, persistent, signals); 169 should_add = true;
170 return MOJO_RESULT_FAILED_PRECONDITION;
171 }
172 170
173 awakable_list_.Add(awakable, context, persistent, signals); 171 if (should_add)
174 return MOJO_RESULT_OK; 172 awakable_list_.Add(awakable, context, persistent, signals, state);
173 return rv;
175 } 174 }
176 175
177 void LocalMessagePipeEndpoint::RemoveAwakable( 176 void LocalMessagePipeEndpoint::RemoveAwakable(
178 bool match_context, 177 bool match_context,
179 Awakable* awakable, 178 Awakable* awakable,
180 uint64_t context, 179 uint64_t context,
181 HandleSignalsState* signals_state) { 180 HandleSignalsState* signals_state) {
182 DCHECK(is_open_); 181 DCHECK(is_open_);
183 awakable_list_.Remove(match_context, awakable, context); 182 awakable_list_.Remove(match_context, awakable, context);
184 if (signals_state) 183 if (signals_state)
185 *signals_state = GetHandleSignalsState(); 184 *signals_state = GetHandleSignalsState();
186 } 185 }
187 186
188 } // namespace system 187 } // namespace system
189 } // namespace mojo 188 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/data_pipe.cc ('k') | mojo/edk/system/simple_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698