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

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

Issue 2068483002: Add an unconditional version of DispatcherAddAwakable(): AddAwakableUnconditional(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: oops 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/dispatcher.h ('k') | mojo/edk/system/local_message_pipe_endpoint.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/dispatcher.h" 5 #include "mojo/edk/system/dispatcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/edk/system/configuration.h" 8 #include "mojo/edk/system/configuration.h"
9 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" 9 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h"
10 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" 10 #include "mojo/edk/system/data_pipe_producer_dispatcher.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 MojoHandleSignals signals, 318 MojoHandleSignals signals,
319 uint64_t context, 319 uint64_t context,
320 HandleSignalsState* signals_state) { 320 HandleSignalsState* signals_state) {
321 MutexLocker locker(&mutex_); 321 MutexLocker locker(&mutex_);
322 if (is_closed_) { 322 if (is_closed_) {
323 if (signals_state) 323 if (signals_state)
324 *signals_state = HandleSignalsState(); 324 *signals_state = HandleSignalsState();
325 return MOJO_RESULT_INVALID_ARGUMENT; 325 return MOJO_RESULT_INVALID_ARGUMENT;
326 } 326 }
327 327
328 return AddAwakableImplNoLock(awakable, signals, context, signals_state); 328 return AddAwakableImplNoLock(awakable, signals, false, context,
329 signals_state);
330 }
331
332 MojoResult Dispatcher::AddAwakableUnconditional(
333 Awakable* awakable,
334 MojoHandleSignals signals,
335 uint64_t context,
336 HandleSignalsState* signals_state) {
337 MutexLocker locker(&mutex_);
338 if (is_closed_) {
339 if (signals_state)
340 *signals_state = HandleSignalsState();
341 return MOJO_RESULT_INVALID_ARGUMENT;
342 }
343
344 return AddAwakableImplNoLock(awakable, signals, true, context, signals_state);
329 } 345 }
330 346
331 void Dispatcher::RemoveAwakable(Awakable* awakable, 347 void Dispatcher::RemoveAwakable(Awakable* awakable,
332 HandleSignalsState* handle_signals_state) { 348 HandleSignalsState* handle_signals_state) {
333 MutexLocker locker(&mutex_); 349 MutexLocker locker(&mutex_);
334 if (is_closed_) { 350 if (is_closed_) {
335 if (handle_signals_state) 351 if (handle_signals_state)
336 *handle_signals_state = HandleSignalsState(); 352 *handle_signals_state = HandleSignalsState();
337 return; 353 return;
338 } 354 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 mutex_.AssertHeld(); 560 mutex_.AssertHeld();
545 DCHECK(!is_closed_); 561 DCHECK(!is_closed_);
546 // By default, waiting isn't supported. Only dispatchers that can be waited on 562 // By default, waiting isn't supported. Only dispatchers that can be waited on
547 // will do something nontrivial. 563 // will do something nontrivial.
548 return HandleSignalsState(); 564 return HandleSignalsState();
549 } 565 }
550 566
551 MojoResult Dispatcher::AddAwakableImplNoLock( 567 MojoResult Dispatcher::AddAwakableImplNoLock(
552 Awakable* /*awakable*/, 568 Awakable* /*awakable*/,
553 MojoHandleSignals /*signals*/, 569 MojoHandleSignals /*signals*/,
570 bool /*force*/,
554 uint64_t /*context*/, 571 uint64_t /*context*/,
555 HandleSignalsState* signals_state) { 572 HandleSignalsState* signals_state) {
556 mutex_.AssertHeld(); 573 mutex_.AssertHeld();
557 DCHECK(!is_closed_); 574 DCHECK(!is_closed_);
558 // By default, waiting isn't supported. Only dispatchers that can be waited on 575 // By default, waiting isn't supported. Only dispatchers that can be waited on
559 // will do something nontrivial. 576 // will do something nontrivial.
560 if (signals_state) 577 if (signals_state)
561 *signals_state = HandleSignalsState(); 578 *signals_state = HandleSignalsState();
562 return MOJO_RESULT_FAILED_PRECONDITION; 579 return MOJO_RESULT_FAILED_PRECONDITION;
563 } 580 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 // want to remove or weaken). 661 // want to remove or weaken).
645 MutexLocker locker(&mutex_); 662 MutexLocker locker(&mutex_);
646 #endif 663 #endif
647 664
648 return EndSerializeAndCloseImplNoLock(channel, destination, actual_size, 665 return EndSerializeAndCloseImplNoLock(channel, destination, actual_size,
649 platform_handles); 666 platform_handles);
650 } 667 }
651 668
652 } // namespace system 669 } // namespace system
653 } // namespace mojo 670 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/dispatcher.h ('k') | mojo/edk/system/local_message_pipe_endpoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698