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

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

Issue 2056763003: EDK: Change Awakable::Awake()'s context, etc., to be a uint64_t. (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/core.h ('k') | mojo/edk/system/core_test_base.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/core.h" 5 #include "mojo/edk/system/core.h"
6 6
7 #include <limits>
7 #include <memory> 8 #include <memory>
8 #include <utility> 9 #include <utility>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "mojo/edk/embedder/platform_support.h" 13 #include "mojo/edk/embedder/platform_support.h"
13 #include "mojo/edk/platform/platform_shared_buffer.h" 14 #include "mojo/edk/platform/platform_shared_buffer.h"
14 #include "mojo/edk/platform/time_ticks.h" 15 #include "mojo/edk/platform/time_ticks.h"
15 #include "mojo/edk/system/async_waiter.h" 16 #include "mojo/edk/system/async_waiter.h"
16 #include "mojo/edk/system/configuration.h" 17 #include "mojo/edk/system/configuration.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 234 }
234 235
235 new_handle.Put(new_handle_value); 236 new_handle.Put(new_handle_value);
236 return MOJO_RESULT_OK; 237 return MOJO_RESULT_OK;
237 } 238 }
238 239
239 MojoResult Core::Wait(MojoHandle handle, 240 MojoResult Core::Wait(MojoHandle handle,
240 MojoHandleSignals signals, 241 MojoHandleSignals signals,
241 MojoDeadline deadline, 242 MojoDeadline deadline,
242 UserPointer<MojoHandleSignalsState> signals_state) { 243 UserPointer<MojoHandleSignalsState> signals_state) {
243 uint32_t unused = static_cast<uint32_t>(-1); 244 uint64_t unused = static_cast<uint64_t>(-1);
244 HandleSignalsState hss; 245 HandleSignalsState hss;
245 MojoResult result = WaitManyInternal(&handle, &signals, 1, deadline, &unused, 246 MojoResult result = WaitManyInternal(&handle, &signals, 1, deadline, &unused,
246 signals_state.IsNull() ? nullptr : &hss); 247 signals_state.IsNull() ? nullptr : &hss);
247 if (result != MOJO_RESULT_INVALID_ARGUMENT && !signals_state.IsNull()) 248 if (result != MOJO_RESULT_INVALID_ARGUMENT && !signals_state.IsNull())
248 signals_state.Put(hss); 249 signals_state.Put(hss);
249 return result; 250 return result;
250 } 251 }
251 252
252 MojoResult Core::WaitMany(UserPointer<const MojoHandle> handles, 253 MojoResult Core::WaitMany(UserPointer<const MojoHandle> handles,
253 UserPointer<const MojoHandleSignals> signals, 254 UserPointer<const MojoHandleSignals> signals,
254 uint32_t num_handles, 255 uint32_t num_handles,
255 MojoDeadline deadline, 256 MojoDeadline deadline,
256 UserPointer<uint32_t> result_index, 257 UserPointer<uint32_t> result_index,
257 UserPointer<MojoHandleSignalsState> signals_states) { 258 UserPointer<MojoHandleSignalsState> signals_states) {
258 if (num_handles < 1) 259 if (num_handles < 1)
259 return MOJO_RESULT_INVALID_ARGUMENT; 260 return MOJO_RESULT_INVALID_ARGUMENT;
260 if (num_handles > GetConfiguration().max_wait_many_num_handles) 261 if (num_handles > GetConfiguration().max_wait_many_num_handles)
261 return MOJO_RESULT_RESOURCE_EXHAUSTED; 262 return MOJO_RESULT_RESOURCE_EXHAUSTED;
262 263
263 UserPointer<const MojoHandle>::Reader handles_reader(handles, num_handles); 264 UserPointer<const MojoHandle>::Reader handles_reader(handles, num_handles);
264 UserPointer<const MojoHandleSignals>::Reader signals_reader(signals, 265 UserPointer<const MojoHandleSignals>::Reader signals_reader(signals,
265 num_handles); 266 num_handles);
266 uint32_t index = static_cast<uint32_t>(-1); 267 uint64_t index = static_cast<uint64_t>(-1);
267 MojoResult result; 268 MojoResult result;
268 if (signals_states.IsNull()) { 269 if (signals_states.IsNull()) {
269 result = WaitManyInternal(handles_reader.GetPointer(), 270 result = WaitManyInternal(handles_reader.GetPointer(),
270 signals_reader.GetPointer(), num_handles, 271 signals_reader.GetPointer(), num_handles,
271 deadline, &index, nullptr); 272 deadline, &index, nullptr);
272 } else { 273 } else {
273 UserPointer<MojoHandleSignalsState>::Writer signals_states_writer( 274 UserPointer<MojoHandleSignalsState>::Writer signals_states_writer(
274 signals_states, num_handles); 275 signals_states, num_handles);
275 // Note: The |reinterpret_cast| is safe, since |HandleSignalsState| is a 276 // Note: The |reinterpret_cast| is safe, since |HandleSignalsState| is a
276 // subclass of |MojoHandleSignalsState| that doesn't add any data members. 277 // subclass of |MojoHandleSignalsState| that doesn't add any data members.
277 result = WaitManyInternal( 278 result = WaitManyInternal(
278 handles_reader.GetPointer(), signals_reader.GetPointer(), num_handles, 279 handles_reader.GetPointer(), signals_reader.GetPointer(), num_handles,
279 deadline, &index, reinterpret_cast<HandleSignalsState*>( 280 deadline, &index, reinterpret_cast<HandleSignalsState*>(
280 signals_states_writer.GetPointer())); 281 signals_states_writer.GetPointer()));
281 if (result != MOJO_RESULT_INVALID_ARGUMENT) 282 if (result != MOJO_RESULT_INVALID_ARGUMENT)
282 signals_states_writer.Commit(); 283 signals_states_writer.Commit();
283 } 284 }
284 if (index != static_cast<uint32_t>(-1) && !result_index.IsNull()) 285 if (index != static_cast<uint64_t>(-1) && !result_index.IsNull()) {
285 result_index.Put(index); 286 DCHECK_LE(index, std::numeric_limits<uint32_t>::max());
287 result_index.Put(static_cast<uint32_t>(index));
288 }
286 return result; 289 return result;
287 } 290 }
288 291
289 MojoResult Core::CreateMessagePipe( 292 MojoResult Core::CreateMessagePipe(
290 UserPointer<const MojoCreateMessagePipeOptions> options, 293 UserPointer<const MojoCreateMessagePipeOptions> options,
291 UserPointer<MojoHandle> message_pipe_handle0, 294 UserPointer<MojoHandle> message_pipe_handle0,
292 UserPointer<MojoHandle> message_pipe_handle1) { 295 UserPointer<MojoHandle> message_pipe_handle1) {
293 MojoCreateMessagePipeOptions validated_options = {}; 296 MojoCreateMessagePipeOptions validated_options = {};
294 MojoResult result = 297 MojoResult result =
295 MessagePipeDispatcher::ValidateCreateOptions(options, &validated_options); 298 MessagePipeDispatcher::ValidateCreateOptions(options, &validated_options);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 } 751 }
749 752
750 // Note: We allow |handles| to repeat the same handle multiple times, since 753 // Note: We allow |handles| to repeat the same handle multiple times, since
751 // different flags may be specified. 754 // different flags may be specified.
752 // TODO(vtl): This incurs a performance cost in |Remove()|. Analyze this 755 // TODO(vtl): This incurs a performance cost in |Remove()|. Analyze this
753 // more carefully and address it if necessary. 756 // more carefully and address it if necessary.
754 MojoResult Core::WaitManyInternal(const MojoHandle* handles, 757 MojoResult Core::WaitManyInternal(const MojoHandle* handles,
755 const MojoHandleSignals* signals, 758 const MojoHandleSignals* signals,
756 uint32_t num_handles, 759 uint32_t num_handles,
757 MojoDeadline deadline, 760 MojoDeadline deadline,
758 uint32_t* result_index, 761 uint64_t* result_index,
759 HandleSignalsState* signals_states) { 762 HandleSignalsState* signals_states) {
760 DCHECK_GT(num_handles, 0u); 763 DCHECK_GT(num_handles, 0u);
761 DCHECK_EQ(*result_index, static_cast<uint32_t>(-1)); 764 DCHECK_EQ(*result_index, static_cast<uint64_t>(-1));
762 765
763 DispatcherVector dispatchers; 766 DispatcherVector dispatchers;
764 dispatchers.reserve(num_handles); 767 dispatchers.reserve(num_handles);
765 768
766 { 769 {
767 MutexLocker locker(&handle_table_mutex_); 770 MutexLocker locker(&handle_table_mutex_);
768 for (uint32_t i = 0; i < num_handles; i++) { 771 for (uint32_t i = 0; i < num_handles; i++) {
769 if (handles[i] == MOJO_HANDLE_INVALID) { 772 if (handles[i] == MOJO_HANDLE_INVALID) {
770 *result_index = i; 773 *result_index = i;
771 return MOJO_RESULT_INVALID_ARGUMENT; 774 return MOJO_RESULT_INVALID_ARGUMENT;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 if (signals_states) { 815 if (signals_states) {
813 for (; i < num_handles; i++) 816 for (; i < num_handles; i++)
814 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); 817 signals_states[i] = dispatchers[i]->GetHandleSignalsState();
815 } 818 }
816 819
817 return result; 820 return result;
818 } 821 }
819 822
820 } // namespace system 823 } // namespace system
821 } // namespace mojo 824 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/core.h ('k') | mojo/edk/system/core_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698