Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 #ifndef MOJO_PUBLIC_CPP_SYSTEM_WAIT_H_ | |
| 6 #define MOJO_PUBLIC_CPP_SYSTEM_WAIT_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include "mojo/public/c/system/types.h" | |
| 11 #include "mojo/public/cpp/system/handle.h" | |
| 12 #include "mojo/public/cpp/system/system_export.h" | |
| 13 | |
| 14 namespace mojo { | |
| 15 | |
| 16 // Blocks the calling thread, waiting for one or more signals in |signals| to be | |
| 17 // become satisfied -- or for all of them to become unsatisfiable -- on the | |
| 18 // given Handle. | |
| 19 // | |
| 20 // If |signals_state| is non-null, |handle| is valid, the wait is not cancelled | |
| 21 // (see return values below), the last known signaling state of |handle| is | |
| 22 // written to |*signals_state| before returning. | |
| 23 // | |
| 24 // Return values: | |
| 25 // |MOJO_RESULT_OK| if one or more signals in |signals| has been raised on | |
| 26 // |handle| . | |
| 27 // |MOJO_RESULT_FAILED_PRECONDITION| if the state of |handle| changes such | |
| 28 // that no signals in |signals| can ever be raised again. | |
| 29 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. | |
| 30 // |MOJO_RESULT_CANCELLED| if the wait was cancelled because |handle| was | |
| 31 // closed by some other thread while waiting. | |
| 32 MOJO_CPP_SYSTEM_EXPORT MojoResult | |
| 33 Wait(Handle handle, | |
| 34 MojoHandleSignals signals, | |
| 35 MojoHandleSignalsState* signals_state = nullptr); | |
| 36 | |
| 37 // Blocks the calling thread, waiting for any handle in |handles| to have one of | |
| 38 // the corresponding signals in |signals| become satisfied or to have all of the | |
|
yzshen1
2017/03/17 17:10:27
nit: At the first glance, I thought this method ab
Ken Rockot(use gerrit already)
2017/03/17 17:58:51
Agreed. Fixed!
| |
| 39 // corresponding signals in |signals| become permanently unsatisfiable. | |
| 40 // | |
| 41 // |num_handles| specifies the number of Handle entries at |handles| as well as | |
| 42 // the number of signals values in |signals|. Each entry in |signals| | |
| 43 // corresponds to the signals to watch for the corresponding entry in |handles|. | |
| 44 // | |
| 45 // If |signals_states| is non-null, all other arguments are valid, and the wait | |
| 46 // is not cancelled (see return values below), the last known signaling state of | |
| 47 // each Handle in |handles| is written to its corresponding entry in | |
| 48 // |signals_states| before returning. | |
| 49 // | |
| 50 // Returns values: | |
| 51 // |MOJO_RESULT_OK| if one of the Handles in |handles| had one or more of its | |
| 52 // correpsonding signals satisfied. |*result_index| contains the index | |
| 53 // of the Handle in question if |result_index| is non-null. | |
| 54 // |MOJO_RESULT_FAILED_PRECONDITION| if one of the Handles in |handles| | |
| 55 // changes state such that its corresponding signals become permanently | |
| 56 // unsatisfiable. |*result_index| contains the index of the handle in | |
| 57 // question if |result_index| is non-null. | |
| 58 // |MOJO_RESULT_INVALID_ARGUMENT| if any Handle in |handles| is invalid, | |
| 59 // or if any of |handles|, |signals|, or |result_index| is null. | |
|
yzshen1
2017/03/17 17:10:27
I thought |result_index| is allowed to be null?
Ken Rockot(use gerrit already)
2017/03/17 17:58:51
Indeed. Outdated comment. :)
Fixed!
| |
| 60 // |MOJO_RESULT_CANCELLED| if the wait was cancelled because a handle in | |
| 61 // |handles| was closed by some other thread while waiting. | |
| 62 // |*result_index| contains the index of the closed Handle if | |
| 63 // |result_index| is non-null. | |
| 64 MOJO_CPP_SYSTEM_EXPORT MojoResult | |
| 65 WaitMany(const Handle* handles, | |
| 66 const MojoHandleSignals* signals, | |
| 67 size_t num_handles, | |
| 68 size_t* result_index = nullptr, | |
| 69 MojoHandleSignalsState* signals_states = nullptr); | |
| 70 | |
| 71 } // namespace mojo | |
| 72 | |
| 73 #endif // MOJO_PUBLIC_CPP_SYSTEM_WAIT_H_ | |
| OLD | NEW |