| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // This file contains functions for waiting on multiple handles using wait sets. | 5 // This file contains functions for waiting on multiple handles using wait sets. |
| 6 // | 6 // |
| 7 // Note: This header should be compilable as C. | 7 // Note: This header should be compilable as C. |
| 8 | 8 |
| 9 #ifndef MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_ | 9 #ifndef MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_ |
| 10 #define MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_ | 10 #define MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 MOJO_STATIC_ASSERT(sizeof(struct MojoWaitSetAddOptions) == 8, | 53 MOJO_STATIC_ASSERT(sizeof(struct MojoWaitSetAddOptions) == 8, |
| 54 "MojoWaitSetAddOptions has wrong size"); | 54 "MojoWaitSetAddOptions has wrong size"); |
| 55 | 55 |
| 56 // |MojoWaitSetResult|: Returned by |MojoWaitSetWait()| to indicate the state of | 56 // |MojoWaitSetResult|: Returned by |MojoWaitSetWait()| to indicate the state of |
| 57 // entries. See |MojoWaitSetWait()| for the values of these fields. | 57 // entries. See |MojoWaitSetWait()| for the values of these fields. |
| 58 | 58 |
| 59 struct MOJO_ALIGNAS(8) MojoWaitSetResult { | 59 struct MOJO_ALIGNAS(8) MojoWaitSetResult { |
| 60 uint64_t cookie; | 60 uint64_t cookie; |
| 61 MojoResult wait_result; | 61 MojoResult wait_result; |
| 62 uint32_t reserved; | 62 uint32_t reserved; |
| 63 MojoHandleSignals satisfied_signals; | 63 struct MojoHandleSignalsState signals_state; |
| 64 MojoHandleSignals satisfiable_signals; | |
| 65 }; | 64 }; |
| 66 MOJO_STATIC_ASSERT(sizeof(struct MojoWaitSetResult) == 24, | 65 MOJO_STATIC_ASSERT(sizeof(struct MojoWaitSetResult) == 24, |
| 67 "MojoWaitSetResult has wrong size"); | 66 "MojoWaitSetResult has wrong size"); |
| 68 | 67 |
| 69 MOJO_BEGIN_EXTERN_C | 68 MOJO_BEGIN_EXTERN_C |
| 70 | 69 |
| 71 // |MojoCreateWaitSet()|: Creates a new wait set. | 70 // |MojoCreateWaitSet()|: Creates a new wait set. |
| 72 // | 71 // |
| 73 // A wait set is an object that can be used to wait for a set of handles to | 72 // A wait set is an object that can be used to wait for a set of handles to |
| 74 // satisfy some set of signals simultaneously. | 73 // satisfy some set of signals simultaneously. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // or more of the signals in the entry | 148 // or more of the signals in the entry |
| 150 // - |MOJO_RESULT_CANCELLED| if the handle referred to by the entry was | 149 // - |MOJO_RESULT_CANCELLED| if the handle referred to by the entry was |
| 151 // closed | 150 // closed |
| 152 // - |MOJO_RESULT_BUSY| if the handle referred to by the entry is currently | 151 // - |MOJO_RESULT_BUSY| if the handle referred to by the entry is currently |
| 153 // in use in some transaction | 152 // in use in some transaction |
| 154 // - |MOJO_RESULT_FAILED_PRECONDITION| if it becomes impossible that the | 153 // - |MOJO_RESULT_FAILED_PRECONDITION| if it becomes impossible that the |
| 155 // handle referred to by the entry will ever satisfy any of entry's | 154 // handle referred to by the entry will ever satisfy any of entry's |
| 156 // signals | 155 // signals |
| 157 // - |reserved| is set to 0 | 156 // - |reserved| is set to 0 |
| 158 // | 157 // |
| 159 // When the |wait_result| is |MOJO_RESULT_OK| or | 158 // When |wait_result| is |MOJO_RESULT_OK| or |MOJO_RESULT_FAILED_PRECONDITION| |
| 160 // |MOJO_RESULT_FAILED_PRECONDITION| the |satisfied_signals| and | 159 // |signals_state| is set to the handle's current signal state; otherwise, it |
| 161 // |satisfiable_signals| entries are set to the signals the handle currently | 160 // is set to a zeroed |MojoHandleSignalsState| (in particular, both fields |
| 162 // satisfies and could possibly satisfy. When the |wait_result| is any other | 161 // will then be |MOJO_HANDLE_SIGNALS_NONE|). |
| 163 // value the |satisfied_signals| and |satisfiable_signals| entries are set to | |
| 164 // |MOJO_HANDLE_SIGNALS_NONE|. | |
| 165 // | 162 // |
| 166 // On any result other than |MOJO_RESULT_OK|, |*num_results|, |*results| and | 163 // On any result other than |MOJO_RESULT_OK|, |*num_results|, |*results| and |
| 167 // |*max_results| are not modified. | 164 // |*max_results| are not modified. |
| 168 // | 165 // |
| 169 // Returns: | 166 // Returns: |
| 170 // |MOJO_RESULT_OK| if one or more entries in the wait set become satisfied or | 167 // |MOJO_RESULT_OK| if one or more entries in the wait set become satisfied or |
| 171 // unsatisfiable. | 168 // unsatisfiable. |
| 172 // |MOJO_RESULT_INVALID_ARGUMENT| if |wait_set_handle| does not refer to a | 169 // |MOJO_RESULT_INVALID_ARGUMENT| if |wait_set_handle| does not refer to a |
| 173 // valid wait set handle. | 170 // valid wait set handle. |
| 174 // |MOJO_RESULT_CANCELLED| if |wait_set_handle| is closed during the wait. | 171 // |MOJO_RESULT_CANCELLED| if |wait_set_handle| is closed during the wait. |
| 175 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if a system/quota/etc. limit was reached. | 172 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if a system/quota/etc. limit was reached. |
| 176 // |MOJO_RESULT_BUSY| if |wait_set_handle| is in use in some transaction. Note | 173 // |MOJO_RESULT_BUSY| if |wait_set_handle| is in use in some transaction. Note |
| 177 // that waiting on a wait set handle does not count as a transaction. It | 174 // that waiting on a wait set handle does not count as a transaction. It |
| 178 // is valid to call |MojoWaitSetWait()| on the same wait set handle | 175 // is valid to call |MojoWaitSetWait()| on the same wait set handle |
| 179 // concurrently from different threads. | 176 // concurrently from different threads. |
| 180 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline is passed without any | 177 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline is passed without any |
| 181 // entries in the wait set becoming satisfied or unsatisfiable. | 178 // entries in the wait set becoming satisfied or unsatisfiable. |
| 182 MojoResult MojoWaitSetWait( | 179 MojoResult MojoWaitSetWait( |
| 183 MojoHandle wait_set_handle, // In. | 180 MojoHandle wait_set_handle, // In. |
| 184 MojoDeadline deadline, // In. | 181 MojoDeadline deadline, // In. |
| 185 uint32_t* MOJO_RESTRICT num_results, // In/out. | 182 uint32_t* MOJO_RESTRICT num_results, // In/out. |
| 186 struct MojoWaitSetResult* MOJO_RESTRICT results, // Out. | 183 struct MojoWaitSetResult* MOJO_RESTRICT results, // Out. |
| 187 uint32_t* MOJO_RESTRICT max_results); // Optional out. | 184 uint32_t* MOJO_RESTRICT max_results); // Optional out. |
| 188 | 185 |
| 189 MOJO_END_EXTERN_C | 186 MOJO_END_EXTERN_C |
| 190 | 187 |
| 191 #endif // MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_ | 188 #endif // MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_ |
| OLD | NEW |