OLD | NEW |
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/waiter_test_utils.h" | 5 #include "mojo/edk/system/waiter_test_utils.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 namespace mojo { | 9 namespace mojo { |
8 namespace system { | 10 namespace system { |
9 namespace test { | 11 namespace test { |
10 | 12 |
11 SimpleWaiterThread::SimpleWaiterThread(MojoResult* result, uint32_t* context) | 13 SimpleWaiterThread::SimpleWaiterThread(MojoResult* result, uint32_t* context) |
12 : result_(result), context_(context) { | 14 : result_(result), context_(context) { |
13 waiter_.Init(); | 15 waiter_.Init(); |
14 *result_ = 5420734; // Totally invalid result. | 16 *result_ = 5420734; // Totally invalid result. |
15 *context_ = 23489023; // "Random". | 17 *context_ = 23489023; // "Random". |
16 } | 18 } |
17 | 19 |
18 SimpleWaiterThread::~SimpleWaiterThread() { | 20 SimpleWaiterThread::~SimpleWaiterThread() { |
19 Join(); | 21 Join(); |
20 } | 22 } |
21 | 23 |
22 void SimpleWaiterThread::Run() { | 24 void SimpleWaiterThread::Run() { |
23 *result_ = waiter_.Wait(MOJO_DEADLINE_INDEFINITE, context_); | 25 *result_ = waiter_.Wait(MOJO_DEADLINE_INDEFINITE, context_); |
24 } | 26 } |
25 | 27 |
26 WaiterThread::WaiterThread(scoped_refptr<Dispatcher> dispatcher, | 28 WaiterThread::WaiterThread(RefPtr<Dispatcher>&& dispatcher, |
27 MojoHandleSignals handle_signals, | 29 MojoHandleSignals handle_signals, |
28 MojoDeadline deadline, | 30 MojoDeadline deadline, |
29 uint32_t context, | 31 uint32_t context, |
30 bool* did_wait_out, | 32 bool* did_wait_out, |
31 MojoResult* result_out, | 33 MojoResult* result_out, |
32 uint32_t* context_out, | 34 uint32_t* context_out, |
33 HandleSignalsState* signals_state_out) | 35 HandleSignalsState* signals_state_out) |
34 : dispatcher_(dispatcher), | 36 : dispatcher_(std::move(dispatcher)), |
35 handle_signals_(handle_signals), | 37 handle_signals_(handle_signals), |
36 deadline_(deadline), | 38 deadline_(deadline), |
37 context_(context), | 39 context_(context), |
38 did_wait_out_(did_wait_out), | 40 did_wait_out_(did_wait_out), |
39 result_out_(result_out), | 41 result_out_(result_out), |
40 context_out_(context_out), | 42 context_out_(context_out), |
41 signals_state_out_(signals_state_out) { | 43 signals_state_out_(signals_state_out) { |
42 *did_wait_out_ = false; | 44 *did_wait_out_ = false; |
43 // Initialize these with invalid results (so that we'll be sure to catch any | 45 // Initialize these with invalid results (so that we'll be sure to catch any |
44 // case where they're not set). | 46 // case where they're not set). |
(...skipping 15 matching lines...) Expand all Loading... |
60 return; | 62 return; |
61 | 63 |
62 *did_wait_out_ = true; | 64 *did_wait_out_ = true; |
63 *result_out_ = waiter_.Wait(deadline_, context_out_); | 65 *result_out_ = waiter_.Wait(deadline_, context_out_); |
64 dispatcher_->RemoveAwakable(&waiter_, signals_state_out_); | 66 dispatcher_->RemoveAwakable(&waiter_, signals_state_out_); |
65 } | 67 } |
66 | 68 |
67 } // namespace test | 69 } // namespace test |
68 } // namespace system | 70 } // namespace system |
69 } // namespace mojo | 71 } // namespace mojo |
OLD | NEW |