OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "mojo/public/cpp/bindings/sync_dispatcher.h" | |
6 | |
7 #include <stdlib.h> | |
8 | |
9 #include "mojo/public/cpp/bindings/message.h" | |
10 | |
11 namespace mojo { | |
12 | |
13 bool WaitForMessageAndDispatch(MessagePipeHandle handle, | |
14 MessageReceiver* receiver) { | |
15 while (true) { | |
16 bool result; | |
17 MojoResult rv = ReadAndDispatchMessage(handle, receiver, &result); | |
18 if (rv == MOJO_RESULT_OK) | |
19 return result; | |
20 if (rv == MOJO_RESULT_SHOULD_WAIT) | |
21 rv = Wait(handle, MOJO_WAIT_FLAG_READABLE, MOJO_DEADLINE_INDEFINITE); | |
22 if (rv != MOJO_RESULT_OK) | |
23 return false; | |
24 } | |
25 } | |
26 | |
27 } // namespace mojo | |
OLD | NEW |