Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 basic functions common to different Mojo system APIs. | 5 // This file contains basic functions common to different Mojo system APIs. |
| 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_FUNCTIONS_H_ | 9 #ifndef MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ |
| 10 #define MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ | 10 #define MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 // (e.g., if it has already been closed). | 94 // (e.g., if it has already been closed). |
| 95 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of | 95 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of |
| 96 // handles satisfying any of its signals. | 96 // handles satisfying any of its signals. |
| 97 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME | 97 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME |
| 98 // |handle[i]| will ever satisfy any of the signals in |signals[i]|. | 98 // |handle[i]| will ever satisfy any of the signals in |signals[i]|. |
| 99 MOJO_SYSTEM_EXPORT MojoResult MojoWaitMany(const MojoHandle* handles, | 99 MOJO_SYSTEM_EXPORT MojoResult MojoWaitMany(const MojoHandle* handles, |
| 100 const MojoHandleSignals* signals, | 100 const MojoHandleSignals* signals, |
| 101 uint32_t num_handles, | 101 uint32_t num_handles, |
| 102 MojoDeadline deadline); | 102 MojoDeadline deadline); |
| 103 | 103 |
| 104 // Waits on the given handle until one of the following happens: | |
| 105 // - a signal indicated by |signals| is satisfied. | |
|
viettrungluu
2014/12/02 17:24:55
nit: Capitalize 'a'. (I suppose this is a list of
jimbe
2014/12/02 19:21:18
Done.
| |
| 106 // - it becomes known that no signal indicated by |signals| will ever be | |
|
viettrungluu
2014/12/02 17:24:56
Ditto. Also, the terminating period should be outs
jimbe
2014/12/02 19:21:19
Done. It's now an independent clause, so period st
| |
| 107 // satisfied (see the description of the |MOJO_RESULT_CANCELLED| and | |
| 108 // |MOJO_RESULT_FAILED_PRECONDITION| return values below.) | |
| 109 // - until |deadline| has passed. | |
|
viettrungluu
2014/12/02 17:24:55
" (etc.)
jimbe
2014/12/02 19:21:19
Done.
| |
| 110 // | |
| 111 // If |deadline| is |MOJO_DEADLINE_INDEFINITE|, this will wait "forever" (until | |
| 112 // one of the other wait termination conditions is satisfied). If |deadline| is | |
| 113 // 0, this will return |MOJO_RESULT_DEADLINE_EXCEEDED| only if one of the other | |
| 114 // termination conditions (e.g., a signal is satisfied, or all signals are | |
| 115 // unsatisfiable) is not already satisfied. | |
| 116 // | |
| 117 // |signals_state| (optional) See documentation for |MojoHandleSignalsState|. | |
|
viettrungluu
2014/12/02 17:24:55
nit: colon after "(optional)"
jimbe
2014/12/02 19:21:18
Done.
| |
| 118 // | |
| 119 // Returns: | |
| 120 // |MOJO_RESULT_OK| if some signal in |signals| was satisfied (or is already | |
| 121 // satisfied). | |
| 122 // |MOJO_RESULT_CANCELLED| if |handle| was closed (necessarily from another | |
| 123 // thread) during the wait. | |
| 124 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle (e.g., if | |
| 125 // it has already been closed). The |signals_state| value is unchanged. | |
| 126 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of | |
| 127 // the signals being satisfied. | |
| 128 // |MOJO_RESULT_FAILED_PRECONDITION| if it becomes known that none of the | |
| 129 // signals in |signals| can ever be satisfied (e.g., when waiting on one | |
| 130 // end of a message pipe and the other end is closed). | |
| 131 // | |
| 132 // If there are multiple waiters (on different threads, obviously) waiting on | |
| 133 // the same handle and signal, and that signal becomes is satisfied, all waiters | |
| 134 // will be awoken. | |
| 135 MOJO_SYSTEM_EXPORT MojoResult | |
| 136 MojoNewWait(MojoHandle handle, | |
| 137 MojoHandleSignals signals, | |
| 138 MojoDeadline deadline, | |
| 139 struct MojoHandleSignalsState* signals_state); // Optional out. | |
| 140 | |
| 141 // Waits on |handles[0]|, ..., |handles[num_handles-1]| until: | |
| 142 // - (at least) one handle satisfies a signal indicated in its respective | |
|
viettrungluu
2014/12/02 17:24:55
Needs punctuation, and possibly capitalization.
jimbe
2014/12/02 19:21:19
Done.
| |
| 143 // |signals[0]|, ..., |signals[num_handles-1]| | |
| 144 // - it becomes known that no signal in some |signals[i]| will ever be | |
| 145 // satisfied | |
| 146 // - |deadline| has passed | |
| 147 // | |
| 148 // This means that |MojoWaitMany()| behaves as if |MojoWait()| were called on | |
| 149 // each handle/signals pair simultaneously, completing when the first | |
| 150 // |MojoWait()| would complete. | |
| 151 // | |
| 152 // See |MojoWait()| for more details about |deadline|. | |
| 153 // | |
| 154 // |result_index| (optional) is returned to indicate the index of the handle | |
| 155 // that caused the call to return. For example, the index |i| (from 0 to | |
|
viettrungluu
2014/12/02 17:24:55
nit: "is returned" -> "is used to return"
jimbe
2014/12/02 19:21:19
Done.
| |
| 156 // |num_handles-1|) if |handle[i]| satisfies a signal from |signals[i]|. You | |
| 157 // must manually initialize this to -1 before you make this call because | |
|
viettrungluu
2014/12/02 17:24:55
"-1" -> "a suitable sentinel value" (also add "(e.
jimbe
2014/12/02 19:21:18
Done.
| |
| 158 // this value is not updated if there is no specific handle that causes the | |
| 159 // function to return. Pass null if you don't need this value to be | |
| 160 // returned. | |
| 161 // | |
| 162 // |signals_states| (optional) points to an array of size |num_handles| of | |
| 163 // MojoHandleSignalsState. See |MojoHandleSignalsState| for more details | |
| 164 // about the meaning of each array entry. This array is not an atomic | |
| 165 // snapshot. The array will be updated if the function does not return | |
| 166 // |MOJO_RESULT_INVALID_ARGUMENT| or |MOJO_RESULT_RESOURCE_EXHAUSTED|. | |
| 167 // | |
| 168 // Returns: | |
| 169 // |MOJO_RESULT_CANCELLED| if some |handle[i]| was closed (necessarily from | |
| 170 // another thread) during the wait. | |
| 171 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if there are too many handles. The | |
|
viettrungluu
2014/12/02 17:24:55
nit: here and elsewhere: one space after '.'
jimbe
2014/12/02 19:21:18
Done.
| |
| 172 // |signals_state| array is unchanged. | |
| 173 // |MOJO_RESULT_INVALID_ARGUMENT| if some |handle[i]| is not a valid handle | |
| 174 // (e.g., if it is NULL or if it has already been closed). The | |
|
viettrungluu
2014/12/02 17:24:55
"NULL" here is incorrect.
jimbe
2014/12/02 19:21:18
Done.
| |
| 175 // |signals_state| array is unchanged. | |
| 176 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of | |
| 177 // handles satisfying any of its signals. | |
| 178 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME | |
| 179 // |handle[i]| will ever satisfy any of the signals in |signals[i]|. | |
| 180 MOJO_SYSTEM_EXPORT MojoResult | |
| 181 MojoNewWaitMany(const MojoHandle* handles, | |
| 182 const MojoHandleSignals* signals, | |
| 183 uint32_t num_handles, | |
| 184 MojoDeadline deadline, | |
| 185 uint32_t* result_index, // Optional out | |
| 186 struct MojoHandleSignalsState* signals_states); // Optional out | |
| 187 | |
| 104 #ifdef __cplusplus | 188 #ifdef __cplusplus |
| 105 } // extern "C" | 189 } // extern "C" |
| 106 #endif | 190 #endif |
| 107 | 191 |
| 108 #endif // MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ | 192 #endif // MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ |
| OLD | NEW |