| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef MOJO_PUBLIC_SYSTEM_CORE_H_ | 5 #ifndef MOJO_PUBLIC_SYSTEM_CORE_H_ |
| 6 #define MOJO_PUBLIC_SYSTEM_CORE_H_ | 6 #define MOJO_PUBLIC_SYSTEM_CORE_H_ |
| 7 | 7 |
| 8 // Note: This header should be compilable as C. | 8 // Note: This header should be compilable as C. |
| 9 | 9 |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 | 11 |
| 12 #include "mojo/public/system/system_export.h" |
| 13 |
| 12 // Types ----------------------------------------------------------------------- | 14 // Types ----------------------------------------------------------------------- |
| 13 | 15 |
| 14 // TODO(vtl): Notes: Use of undefined flags will lead to undefined behavior | 16 // TODO(vtl): Notes: Use of undefined flags will lead to undefined behavior |
| 15 // (typically they'll be ignored), not necessarily an error. | 17 // (typically they'll be ignored), not necessarily an error. |
| 16 | 18 |
| 17 // Handles to Mojo objects. | 19 // Handles to Mojo objects. |
| 18 typedef uint32_t MojoHandle; | 20 typedef uint32_t MojoHandle; |
| 19 | 21 |
| 20 // Result codes for Mojo operations. Non-negative values are success codes; | 22 // Result codes for Mojo operations. Non-negative values are success codes; |
| 21 // negative values are error/failure codes. | 23 // negative values are error/failure codes. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // Closes the given |handle|. | 185 // Closes the given |handle|. |
| 184 // | 186 // |
| 185 // Returns: | 187 // Returns: |
| 186 // |MOJO_RESULT_OK| on success. | 188 // |MOJO_RESULT_OK| on success. |
| 187 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. | 189 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. |
| 188 // | 190 // |
| 189 // Concurrent operations on |handle| may succeed (or fail as usual) if they | 191 // Concurrent operations on |handle| may succeed (or fail as usual) if they |
| 190 // happen before the close, be cancelled with result |MOJO_RESULT_CANCELLED| if | 192 // happen before the close, be cancelled with result |MOJO_RESULT_CANCELLED| if |
| 191 // they properly overlap (this is likely the case with |MojoWait()|, etc.), or | 193 // they properly overlap (this is likely the case with |MojoWait()|, etc.), or |
| 192 // fail with |MOJO_RESULT_INVALID_ARGUMENT| if they happen after. | 194 // fail with |MOJO_RESULT_INVALID_ARGUMENT| if they happen after. |
| 193 MojoResult MojoClose(MojoHandle handle); | 195 MOJO_SYSTEM_EXPORT MojoResult MojoClose(MojoHandle handle); |
| 194 | 196 |
| 195 // Waits on the given handle until the state indicated by |flags| is satisfied | 197 // Waits on the given handle until the state indicated by |flags| is satisfied |
| 196 // or until |deadline| has passed. | 198 // or until |deadline| has passed. |
| 197 // | 199 // |
| 198 // Returns: | 200 // Returns: |
| 199 // |MOJO_RESULT_OK| if some flag in |flags| was satisfied (or is already | 201 // |MOJO_RESULT_OK| if some flag in |flags| was satisfied (or is already |
| 200 // satisfied). | 202 // satisfied). |
| 201 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle (e.g., if | 203 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle (e.g., if |
| 202 // it has already been closed). | 204 // it has already been closed). |
| 203 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of | 205 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of |
| 204 // the flags being satisfied. | 206 // the flags being satisfied. |
| 205 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that any | 207 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that any |
| 206 // flag in |flags| will ever be satisfied. | 208 // flag in |flags| will ever be satisfied. |
| 207 // | 209 // |
| 208 // If there are multiple waiters (on different threads, obviously) waiting on | 210 // If there are multiple waiters (on different threads, obviously) waiting on |
| 209 // the same handle and flag and that flag becomes set, all waiters will be | 211 // the same handle and flag and that flag becomes set, all waiters will be |
| 210 // awoken. | 212 // awoken. |
| 211 MojoResult MojoWait(MojoHandle handle, | 213 MOJO_SYSTEM_EXPORT MojoResult MojoWait(MojoHandle handle, |
| 212 MojoWaitFlags flags, | 214 MojoWaitFlags flags, |
| 213 MojoDeadline deadline); | 215 MojoDeadline deadline); |
| 214 | 216 |
| 215 // Waits on |handles[0]|, ..., |handles[num_handles-1]| for at least one of them | 217 // Waits on |handles[0]|, ..., |handles[num_handles-1]| for at least one of them |
| 216 // to satisfy the state indicated by |flags[0]|, ..., |flags[num_handles-1]|, | 218 // to satisfy the state indicated by |flags[0]|, ..., |flags[num_handles-1]|, |
| 217 // respectively, or until |deadline| has passed. | 219 // respectively, or until |deadline| has passed. |
| 218 // | 220 // |
| 219 // Returns: | 221 // Returns: |
| 220 // The index |i| (from 0 to |num_handles-1|) if |handle[i]| satisfies | 222 // The index |i| (from 0 to |num_handles-1|) if |handle[i]| satisfies |
| 221 // |flags[i]|. | 223 // |flags[i]|. |
| 222 // |MOJO_RESULT_INVALID_ARGUMENT| if some |handle[i]| is not a valid handle | 224 // |MOJO_RESULT_INVALID_ARGUMENT| if some |handle[i]| is not a valid handle |
| 223 // (e.g., if it has already been closed). | 225 // (e.g., if it has already been closed). |
| 224 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of | 226 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of |
| 225 // handles satisfying any of its flags. | 227 // handles satisfying any of its flags. |
| 226 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME | 228 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME |
| 227 // |handle[i]| will ever satisfy any of its flags |flags[i]|. | 229 // |handle[i]| will ever satisfy any of its flags |flags[i]|. |
| 228 MojoResult MojoWaitMany(const MojoHandle* handles, | 230 MOJO_SYSTEM_EXPORT MojoResult MojoWaitMany(const MojoHandle* handles, |
| 229 const MojoWaitFlags* flags, | 231 const MojoWaitFlags* flags, |
| 230 uint32_t num_handles, | 232 uint32_t num_handles, |
| 231 MojoDeadline deadline); | 233 MojoDeadline deadline); |
| 232 | 234 |
| 233 // TODO(vtl): flags? other params (e.g., queue sizes, max message sizes?) | 235 // TODO(vtl): flags? other params (e.g., queue sizes, max message sizes?) |
| 234 MojoResult MojoCreateMessagePipe(MojoHandle* handle_0, MojoHandle* handle_1); | 236 MOJO_SYSTEM_EXPORT MojoResult MojoCreateMessagePipe(MojoHandle* handle_0, |
| 237 MojoHandle* handle_1); |
| 235 | 238 |
| 236 MojoResult MojoWriteMessage(MojoHandle handle, | 239 MOJO_SYSTEM_EXPORT MojoResult MojoWriteMessage( |
| 237 const void* bytes, uint32_t num_bytes, | 240 MojoHandle handle, |
| 238 const MojoHandle* handles, uint32_t num_handles, | 241 const void* bytes, uint32_t num_bytes, |
| 239 MojoWriteMessageFlags flags); | 242 const MojoHandle* handles, |
| 243 uint32_t num_handles, |
| 244 MojoWriteMessageFlags flags); |
| 240 | 245 |
| 241 MojoResult MojoReadMessage(MojoHandle handle, | 246 MOJO_SYSTEM_EXPORT MojoResult MojoReadMessage(MojoHandle handle, |
| 242 void* bytes, uint32_t* num_bytes, | 247 void* bytes, uint32_t* num_bytes, |
| 243 MojoHandle* handles, uint32_t* num_handles, | 248 MojoHandle* handles, |
| 244 MojoReadMessageFlags flags); | 249 uint32_t* num_handles, |
| 250 MojoReadMessageFlags flags); |
| 245 | 251 |
| 246 #ifdef __cplusplus | 252 #ifdef __cplusplus |
| 247 } // extern "C" | 253 } // extern "C" |
| 248 #endif | 254 #endif |
| 249 | 255 |
| 250 // C++ wrapper functions ------------------------------------------------------- | 256 // C++ wrapper functions ------------------------------------------------------- |
| 251 | 257 |
| 252 #ifdef __cplusplus | 258 #ifdef __cplusplus |
| 253 | 259 |
| 254 namespace mojo { | 260 namespace mojo { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 return MojoReadMessage(handle.value, | 312 return MojoReadMessage(handle.value, |
| 307 bytes, num_bytes, | 313 bytes, num_bytes, |
| 308 &handles[0].value, num_handles, | 314 &handles[0].value, num_handles, |
| 309 flags); | 315 flags); |
| 310 } | 316 } |
| 311 | 317 |
| 312 } // namespace mojo | 318 } // namespace mojo |
| 313 #endif | 319 #endif |
| 314 | 320 |
| 315 #endif // MOJO_PUBLIC_SYSTEM_CORE_H_ | 321 #endif // MOJO_PUBLIC_SYSTEM_CORE_H_ |
| OLD | NEW |