| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // |MojoWaitSetAddOptions|: Used to specify parameters in adding an entry to a | 35 // |MojoWaitSetAddOptions|: Used to specify parameters in adding an entry to a |
| 36 // wait set with |MojoWaitSetAdd()|. | 36 // wait set with |MojoWaitSetAdd()|. |
| 37 // |uint32_t struct_size|: Set to the size of the |MojoWaitSetAddOptions| | 37 // |uint32_t struct_size|: Set to the size of the |MojoWaitSetAddOptions| |
| 38 // struct. (Used to allow for future extensions.) | 38 // struct. (Used to allow for future extensions.) |
| 39 // |MojoWaitSetAddOptionsFlags flags|: Reserved for future use. | 39 // |MojoWaitSetAddOptionsFlags flags|: Reserved for future use. |
| 40 // |MOJO_WAIT_SET_ADD_OPTIONS_FLAGS_NONE|: No flags, default mode. | 40 // |MOJO_WAIT_SET_ADD_OPTIONS_FLAGS_NONE|: No flags, default mode. |
| 41 | 41 |
| 42 typedef uint32_t MojoWaitSetAddOptionsFlags; | 42 typedef uint32_t MojoWaitSetAddOptionsFlags; |
| 43 | 43 |
| 44 #define MOJO_CREATE_WAIT_SET_OPTIONS_FLAG_NONE \ |
| 45 ((MojoCreateWaitSetOptionsFlags)0) |
| 46 |
| 44 struct MOJO_ALIGNAS(8) MojoWaitSetAddOptions { | 47 struct MOJO_ALIGNAS(8) MojoWaitSetAddOptions { |
| 45 uint32_t struct_size; | 48 uint32_t struct_size; |
| 46 MojoWaitSetAddOptionsFlags flags; | 49 MojoWaitSetAddOptionsFlags flags; |
| 47 }; | 50 }; |
| 48 MOJO_STATIC_ASSERT(sizeof(MojoWaitSetAddOptions) == 8, | 51 MOJO_STATIC_ASSERT(sizeof(MojoWaitSetAddOptions) == 8, |
| 49 "MojoWaitSetAddOptions has wrong size"); | 52 "MojoWaitSetAddOptions has wrong size"); |
| 50 | 53 |
| 51 // |MojoWaitSetResult|: Returned by |MojoWaitSetWait()| to indicate the state of | 54 // |MojoWaitSetResult|: Returned by |MojoWaitSetWait()| to indicate the state of |
| 52 // entries. See |MojoWaitSetWait()| for the values of these fields. | 55 // entries. See |MojoWaitSetWait()| for the values of these fields. |
| 53 | 56 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 74 // |MOJO_RESULT_OK| if a wait set was successfully created. On success, | 77 // |MOJO_RESULT_OK| if a wait set was successfully created. On success, |
| 75 // |*handle| will be the handle of the wait set. | 78 // |*handle| will be the handle of the wait set. |
| 76 // |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., | 79 // |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., |
| 77 // |options| is non null and |*options| is invalid). | 80 // |options| is non null and |*options| is invalid). |
| 78 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if a process/system/quota/etc. limit has | 81 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if a process/system/quota/etc. limit has |
| 79 // been reached. | 82 // been reached. |
| 80 MojoResult MojoCreateWaitSet(const struct MojoCreateWaitSetOptions* | 83 MojoResult MojoCreateWaitSet(const struct MojoCreateWaitSetOptions* |
| 81 MOJO_RESTRICT options, // Optional in. | 84 MOJO_RESTRICT options, // Optional in. |
| 82 MojoHandle* handle); // Out. | 85 MojoHandle* handle); // Out. |
| 83 | 86 |
| 84 // |MojoWaitSetAdd()|: Adds an entry to watch for to the wait set. | 87 // |MojoWaitSetAdd()|: Adds an entry to watch for to the wait set specified by |
| 88 // |wait_set_handle| (which must have the |MOJO_HANDLE_RIGHT_WRITE| right). |
| 85 // | 89 // |
| 86 // An entry in a wait set is composed of a handle, a signal set, and a | 90 // An entry in a wait set is composed of a handle, a signal set, and a |
| 87 // caller-specified cookie value. The cookie value must be unique across all | 91 // caller-specified cookie value. The cookie value must be unique across all |
| 88 // entries in a particular wait set but is otherwise opaque and can be any value | 92 // entries in a particular wait set but is otherwise opaque and can be any value |
| 89 // that is useful to the caller. If |options| is null the default options will | 93 // that is useful to the caller. If |options| is null the default options will |
| 90 // be used. | 94 // be used. |
| 91 // | 95 // |
| 92 // In all failure cases the wait set is unchanged. | 96 // In all failure cases the wait set is unchanged. |
| 93 // | 97 // |
| 94 // Returns: | 98 // Returns: |
| 95 // |MOJO_RESULT_OK| if the handle was added to the wait set. | 99 // |MOJO_RESULT_OK| if the handle was added to the wait set. |
| 96 // |MOJO_RESULT_INVALID_ARGUMENT| if |wait_set_handle| or |handle| do not | 100 // |MOJO_RESULT_INVALID_ARGUMENT| if |wait_set_handle| or |handle| do not |
| 97 // refer to valid handles, |wait_set_handle| is not a handle to a wait | 101 // refer to valid handles, |wait_set_handle| is not a handle to a wait |
| 98 // set, |cookie| is not a unique value within this wait set, or |options| | 102 // set, |cookie| is not a unique value within this wait set, or |options| |
| 99 // is not null and |*options| is not a valid options structure. | 103 // is not null and |*options| is not a valid options structure. |
| 100 // |MOJO_RESULT_BUSY| if |wait_set_handle| or |handle| are currently in use in | 104 // |MOJO_RESULT_BUSY| if |wait_set_handle| or |handle| are currently in use in |
| 101 // some transaction. | 105 // some transaction. |
| 102 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if the handle could not be added due to | 106 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if the handle could not be added due to |
| 103 // hitting a system or quota limitation. | 107 // hitting a system or quota limitation. |
| 104 MojoResult MojoWaitSetAdd(const struct MojoWaitSetAddOptions* MOJO_RESTRICT | 108 MojoResult MojoWaitSetAdd(const struct MojoWaitSetAddOptions* MOJO_RESTRICT |
| 105 options, // Optional in. | 109 options, // Optional in. |
| 106 MojoHandle wait_set_handle, // In. | 110 MojoHandle wait_set_handle, // In. |
| 107 MojoHandle handle, // In. | 111 MojoHandle handle, // In. |
| 108 MojoHandleSignals signals, // In. | 112 MojoHandleSignals signals, // In. |
| 109 uint64_t cookie); // In. | 113 uint64_t cookie); // In. |
| 110 | 114 |
| 111 // |MojoWaitSetRemove()|: Removes an entry from the wait set. | 115 // |MojoWaitSetRemove()|: Removes an entry from the wait set specified by |
| 116 // |wait_set_handle| (which must have the |MOJO_HANDLE_RIGHT_WRITE| right). |
| 112 // | 117 // |
| 113 // Returns: | 118 // Returns: |
| 114 // |MOJO_RESULT_OK| if the entry was successfully removed. | 119 // |MOJO_RESULT_OK| if the entry was successfully removed. |
| 115 // |MOJO_RESULT_INVALID_ARGUMENT| if |wait_set_handle| does not refer to a | 120 // |MOJO_RESULT_INVALID_ARGUMENT| if |wait_set_handle| does not refer to a |
| 116 // valid wait set or if |cookie| does not identify an entry within the | 121 // valid wait set or if |cookie| does not identify an entry within the |
| 117 // wait set. | 122 // wait set. |
| 118 MojoResult MojoWaitSetRemove(MojoHandle wait_set_handle, // In. | 123 MojoResult MojoWaitSetRemove(MojoHandle wait_set_handle, // In. |
| 119 uint64_t cookie); // In. | 124 uint64_t cookie); // In. |
| 120 | 125 |
| 121 // |MojoWaitSetWait()|: Waits on all entries in the wait set for at least one of | 126 // |MojoWaitSetWait()|: Waits on all entries in the wait set specified by |
| 122 // the following: | 127 // |wait_set_handle| (which must have the |MOJO_HANDLE_RIGHT_READ| right) for at |
| 128 // least one of the following: |
| 123 // - At least one entry's handle satisfies a signal in that entry's signal | 129 // - At least one entry's handle satisfies a signal in that entry's signal |
| 124 // set. | 130 // set. |
| 125 // - At least one entry's handle can never satisfy a signal in that entry's | 131 // - At least one entry's handle can never satisfy a signal in that entry's |
| 126 // signal set. | 132 // signal set. |
| 127 // - |deadline| expires. | 133 // - |deadline| expires. |
| 128 // - The wait set is closed. | 134 // - The wait set is closed. |
| 129 // | 135 // |
| 130 // On success, sets |*max_results| to the total number of possible results at | 136 // On success, sets |*max_results| to the total number of possible results at |
| 131 // the time of the call. Also returns information for up to |*num_results| | 137 // the time of the call. Also returns information for up to |*num_results| |
| 132 // entries in |*results| and sets |*num_results| to the number of entries the | 138 // entries in |*results| and sets |*num_results| to the number of entries the |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 MojoResult MojoWaitSetWait( | 177 MojoResult MojoWaitSetWait( |
| 172 MojoHandle wait_set_handle, // In. | 178 MojoHandle wait_set_handle, // In. |
| 173 MojoDeadline deadline, // In. | 179 MojoDeadline deadline, // In. |
| 174 uint32_t* MOJO_RESTRICT num_results, // In/out. | 180 uint32_t* MOJO_RESTRICT num_results, // In/out. |
| 175 struct MojoWaitSetResult* MOJO_RESTRICT results, // Out. | 181 struct MojoWaitSetResult* MOJO_RESTRICT results, // Out. |
| 176 uint32_t* MOJO_RESTRICT max_results); // Optional out. | 182 uint32_t* MOJO_RESTRICT max_results); // Optional out. |
| 177 | 183 |
| 178 MOJO_END_EXTERN_C | 184 MOJO_END_EXTERN_C |
| 179 | 185 |
| 180 #endif // MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_ | 186 #endif // MOJO_PUBLIC_C_SYSTEM_WAIT_SET_H_ |
| OLD | NEW |