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

Side by Side Diff: mojo/message_pump/message_pump_mojo.h

Issue 1566573002: Fix race on mojo message pump shutdown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-waitset-message-pump
Patch Set: Revert stuff. Created 4 years, 11 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/message_pump/handle_watcher.cc ('k') | mojo/message_pump/message_pump_mojo.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 #ifndef MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_ 5 #ifndef MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_
6 #define MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_ 6 #define MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop/message_pump.h" 15 #include "base/message_loop/message_pump.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
18 #include "base/synchronization/waitable_event.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "mojo/message_pump/mojo_message_pump_export.h" 20 #include "mojo/message_pump/mojo_message_pump_export.h"
20 #include "mojo/public/cpp/system/core.h" 21 #include "mojo/public/cpp/system/core.h"
21 22
22 namespace mojo { 23 namespace mojo {
23 namespace common { 24 namespace common {
24 25
25 class MessagePumpMojoHandler; 26 class MessagePumpMojoHandler;
26 27
27 // Mojo implementation of MessagePump. 28 // Mojo implementation of MessagePump.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 typedef std::map<Handle, Handler> HandleToHandler; 87 typedef std::map<Handle, Handler> HandleToHandler;
87 88
88 // Implementation of Run(). 89 // Implementation of Run().
89 void DoRunLoop(RunState* run_state, Delegate* delegate); 90 void DoRunLoop(RunState* run_state, Delegate* delegate);
90 91
91 // Services the set of handles ready. If |block| is true this waits for a 92 // Services the set of handles ready. If |block| is true this waits for a
92 // handle to become ready, otherwise this does not block. Returns |true| if a 93 // handle to become ready, otherwise this does not block. Returns |true| if a
93 // handle has become ready, |false| otherwise. 94 // handle has become ready, |false| otherwise.
94 bool DoInternalWork(const RunState& run_state, bool block); 95 bool DoInternalWork(const RunState& run_state, bool block);
95 96
97 bool DoNonMojoWork(const RunState& run_state, bool block);
98
96 // Waits for handles in the wait set to become ready. Returns |true| if ready 99 // Waits for handles in the wait set to become ready. Returns |true| if ready
97 // handles may be available, or |false| if the wait's deadline was exceeded. 100 // handles may be available, or |false| if the wait's deadline was exceeded.
98 // Note, ready handles may be unavailable, even though |true| was returned. 101 // Note, ready handles may be unavailable, even though |true| was returned.
99 bool WaitForReadyHandles(const RunState& run_state) const; 102 bool WaitForReadyHandles(const RunState& run_state) const;
100 103
101 // Retrieves any 'ready' handles from the wait set, and runs the handler's 104 // Retrieves any 'ready' handles from the wait set, and runs the handler's
102 // OnHandleReady() or OnHandleError() functions as necessary. Returns |true| 105 // OnHandleReady() or OnHandleError() functions as necessary. Returns |true|
103 // if any handles were ready and processed. 106 // if any handles were ready and processed.
104 bool ProcessReadyHandles(); 107 bool ProcessReadyHandles();
105 108
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 int next_handler_id_; 150 int next_handler_id_;
148 151
149 base::ObserverList<Observer> observers_; 152 base::ObserverList<Observer> observers_;
150 153
151 // Mojo handle for the wait set. 154 // Mojo handle for the wait set.
152 ScopedHandle wait_set_handle_; 155 ScopedHandle wait_set_handle_;
153 // Used to wake up run loop from |SignalControlPipe()|. 156 // Used to wake up run loop from |SignalControlPipe()|.
154 ScopedMessagePipeHandle read_handle_; 157 ScopedMessagePipeHandle read_handle_;
155 ScopedMessagePipeHandle write_handle_; 158 ScopedMessagePipeHandle write_handle_;
156 159
160 // Used to sleep until there is more work to do, when the Mojo EDK is shutting
161 // down.
162 base::WaitableEvent event_;
163
157 DISALLOW_COPY_AND_ASSIGN(MessagePumpMojo); 164 DISALLOW_COPY_AND_ASSIGN(MessagePumpMojo);
158 }; 165 };
159 166
160 } // namespace common 167 } // namespace common
161 } // namespace mojo 168 } // namespace mojo
162 169
163 #endif // MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_ 170 #endif // MOJO_MESSAGE_PUMP_MESSAGE_PUMP_MOJO_H_
OLDNEW
« no previous file with comments | « mojo/message_pump/handle_watcher.cc ('k') | mojo/message_pump/message_pump_mojo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698