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

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

Issue 2075353002: Plumb the handle signals state out of Waiter::Wait(). (Closed) Base URL: https://github.com/domokit/mojo.git@work795_wait_set_4.3-x-work794_wait_set_4.2
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
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/waiter_test_utils.h" 5 #include "mojo/edk/system/waiter_test_utils.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 using mojo::util::RefPtr; 9 using mojo::util::RefPtr;
10 10
11 namespace mojo { 11 namespace mojo {
12 namespace system { 12 namespace system {
13 namespace test { 13 namespace test {
14 14
15 SimpleWaiterThread::SimpleWaiterThread(MojoResult* result, uint64_t* context) 15 SimpleWaiterThread::SimpleWaiterThread(MojoResult* result, uint64_t* context)
16 : result_(result), context_(context) { 16 : result_(result), context_(context) {
17 waiter_.Init(); 17 waiter_.Init();
18 *result_ = 5420734; // Totally invalid result. 18 *result_ = 5420734; // Totally invalid result.
19 *context_ = 2341532489023ULL; // "Random". 19 *context_ = 2341532489023ULL; // "Random".
20 } 20 }
21 21
22 SimpleWaiterThread::~SimpleWaiterThread() { 22 SimpleWaiterThread::~SimpleWaiterThread() {
23 Join(); 23 Join();
24 } 24 }
25 25
26 void SimpleWaiterThread::Run() { 26 void SimpleWaiterThread::Run() {
27 *result_ = waiter_.Wait(MOJO_DEADLINE_INDEFINITE, context_); 27 *result_ = waiter_.Wait(MOJO_DEADLINE_INDEFINITE, context_, nullptr);
28 } 28 }
29 29
30 WaiterThread::WaiterThread(RefPtr<Dispatcher>&& dispatcher, 30 WaiterThread::WaiterThread(RefPtr<Dispatcher>&& dispatcher,
31 MojoHandleSignals handle_signals, 31 MojoHandleSignals handle_signals,
32 MojoDeadline deadline, 32 MojoDeadline deadline,
33 uint64_t context, 33 uint64_t context,
34 bool* did_wait_out, 34 bool* did_wait_out,
35 MojoResult* result_out, 35 MojoResult* result_out,
36 uint64_t* context_out, 36 uint64_t* context_out,
37 HandleSignalsState* signals_state_out) 37 HandleSignalsState* signals_state_out)
(...skipping 19 matching lines...) Expand all
57 57
58 void WaiterThread::Run() { 58 void WaiterThread::Run() {
59 waiter_.Init(); 59 waiter_.Init();
60 60
61 *result_out_ = dispatcher_->AddAwakable(&waiter_, handle_signals_, context_, 61 *result_out_ = dispatcher_->AddAwakable(&waiter_, handle_signals_, context_,
62 signals_state_out_); 62 signals_state_out_);
63 if (*result_out_ != MOJO_RESULT_OK) 63 if (*result_out_ != MOJO_RESULT_OK)
64 return; 64 return;
65 65
66 *did_wait_out_ = true; 66 *did_wait_out_ = true;
67 *result_out_ = waiter_.Wait(deadline_, context_out_); 67 *result_out_ = waiter_.Wait(deadline_, context_out_, nullptr);
68 dispatcher_->RemoveAwakable(&waiter_, signals_state_out_); 68 dispatcher_->RemoveAwakable(&waiter_, signals_state_out_);
69 } 69 }
70 70
71 } // namespace test 71 } // namespace test
72 } // namespace system 72 } // namespace system
73 } // namespace mojo 73 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698