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

Side by Side Diff: mojo/edk/system/simple_dispatcher.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/local_message_pipe_endpoint.cc ('k') | mojo/edk/system/wait_set_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/simple_dispatcher.h" 5 #include "mojo/edk/system/simple_dispatcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 namespace system { 10 namespace system {
(...skipping 18 matching lines...) Expand all
29 Awakable* awakable, 29 Awakable* awakable,
30 uint64_t context, 30 uint64_t context,
31 bool persistent, 31 bool persistent,
32 MojoHandleSignals signals, 32 MojoHandleSignals signals,
33 HandleSignalsState* signals_state) { 33 HandleSignalsState* signals_state) {
34 mutex().AssertHeld(); 34 mutex().AssertHeld();
35 35
36 HandleSignalsState state(GetHandleSignalsStateImplNoLock()); 36 HandleSignalsState state(GetHandleSignalsStateImplNoLock());
37 if (signals_state) 37 if (signals_state)
38 *signals_state = state; 38 *signals_state = state;
39 if (state.satisfies(signals)) { 39 MojoResult rv = MOJO_RESULT_OK;
40 if (persistent) 40 bool should_add = persistent;
41 awakable_list_.Add(awakable, context, persistent, signals); 41 if (state.satisfies(signals))
42 return MOJO_RESULT_ALREADY_EXISTS; 42 rv = MOJO_RESULT_ALREADY_EXISTS;
43 } 43 else if (!state.can_satisfy(signals))
44 if (!state.can_satisfy(signals)) { 44 rv = MOJO_RESULT_FAILED_PRECONDITION;
45 if (persistent) 45 else
46 awakable_list_.Add(awakable, context, persistent, signals); 46 should_add = true;
47 return MOJO_RESULT_FAILED_PRECONDITION;
48 }
49 47
50 awakable_list_.Add(awakable, context, persistent, signals); 48 if (should_add)
51 return MOJO_RESULT_OK; 49 awakable_list_.Add(awakable, context, persistent, signals, state);
50 return rv;
52 } 51 }
53 52
54 void SimpleDispatcher::RemoveAwakableImplNoLock( 53 void SimpleDispatcher::RemoveAwakableImplNoLock(
55 bool match_context, 54 bool match_context,
56 Awakable* awakable, 55 Awakable* awakable,
57 uint64_t context, 56 uint64_t context,
58 HandleSignalsState* signals_state) { 57 HandleSignalsState* signals_state) {
59 mutex().AssertHeld(); 58 mutex().AssertHeld();
60 awakable_list_.Remove(match_context, awakable, context); 59 awakable_list_.Remove(match_context, awakable, context);
61 if (signals_state) 60 if (signals_state)
62 *signals_state = GetHandleSignalsStateImplNoLock(); 61 *signals_state = GetHandleSignalsStateImplNoLock();
63 } 62 }
64 63
65 } // namespace system 64 } // namespace system
66 } // namespace mojo 65 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/local_message_pipe_endpoint.cc ('k') | mojo/edk/system/wait_set_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698