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

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

Issue 1639093002: Add //mojo/edk/platform/thread_utils.* containing "yield" and "sleep". (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 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/awakable_list_unittest.cc ('k') | mojo/edk/system/core_unittest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/channel_endpoint.h" 5 #include "mojo/edk/system/channel_endpoint.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/platform_thread.h" 10 #include "mojo/edk/platform/thread_utils.h"
11 #include "mojo/edk/system/channel.h" 11 #include "mojo/edk/system/channel.h"
12 #include "mojo/edk/system/channel_endpoint_client.h" 12 #include "mojo/edk/system/channel_endpoint_client.h"
13 #include "mojo/public/cpp/system/macros.h" 13 #include "mojo/public/cpp/system/macros.h"
14 14
15 using mojo::platform::ThreadYield;
15 using mojo::util::MutexLocker; 16 using mojo::util::MutexLocker;
16 using mojo::util::RefPtr; 17 using mojo::util::RefPtr;
17 18
18 namespace mojo { 19 namespace mojo {
19 namespace system { 20 namespace system {
20 21
21 bool ChannelEndpoint::EnqueueMessage( 22 bool ChannelEndpoint::EnqueueMessage(
22 std::unique_ptr<MessageInTransit> message) { 23 std::unique_ptr<MessageInTransit> message) {
23 DCHECK(message); 24 DCHECK(message);
24 25
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Take a ref, and call |OnReadMessage()| outside the lock. 205 // Take a ref, and call |OnReadMessage()| outside the lock.
205 client = client_; 206 client = client_;
206 client_port = client_port_; 207 client_port = client_port_;
207 } 208 }
208 209
209 if (client->OnReadMessage(client_port, message.get())) { 210 if (client->OnReadMessage(client_port, message.get())) {
210 ignore_result(message.release()); 211 ignore_result(message.release());
211 break; 212 break;
212 } 213 }
213 214
214 base::PlatformThread::YieldCurrentThread(); 215 ThreadYield();
215 } 216 }
216 } 217 }
217 218
218 void ChannelEndpoint::DieNoLock() { 219 void ChannelEndpoint::DieNoLock() {
219 DCHECK(state_ == State::RUNNING); 220 DCHECK(state_ == State::RUNNING);
220 DCHECK(channel_); 221 DCHECK(channel_);
221 DCHECK(local_id_.is_valid()); 222 DCHECK(local_id_.is_valid());
222 DCHECK(remote_id_.is_valid()); 223 DCHECK(remote_id_.is_valid());
223 224
224 state_ = State::DEAD; 225 state_ = State::DEAD;
225 channel_ = nullptr; 226 channel_ = nullptr;
226 local_id_ = ChannelEndpointId(); 227 local_id_ = ChannelEndpointId();
227 remote_id_ = ChannelEndpointId(); 228 remote_id_ = ChannelEndpointId();
228 } 229 }
229 230
230 } // namespace system 231 } // namespace system
231 } // namespace mojo 232 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/awakable_list_unittest.cc ('k') | mojo/edk/system/core_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698