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 24 matching lines...) Expand all Loading... |
35 // Returns: | 35 // Returns: |
36 // |MOJO_RESULT_OK| on success. | 36 // |MOJO_RESULT_OK| on success. |
37 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. | 37 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. |
38 // | 38 // |
39 // Concurrent operations on |handle| may succeed (or fail as usual) if they | 39 // Concurrent operations on |handle| may succeed (or fail as usual) if they |
40 // happen before the close, be cancelled with result |MOJO_RESULT_CANCELLED| if | 40 // happen before the close, be cancelled with result |MOJO_RESULT_CANCELLED| if |
41 // they properly overlap (this is likely the case with |MojoWait()|, etc.), or | 41 // they properly overlap (this is likely the case with |MojoWait()|, etc.), or |
42 // fail with |MOJO_RESULT_INVALID_ARGUMENT| if they happen after. | 42 // fail with |MOJO_RESULT_INVALID_ARGUMENT| if they happen after. |
43 MOJO_SYSTEM_EXPORT MojoResult MojoClose(MojoHandle handle); | 43 MOJO_SYSTEM_EXPORT MojoResult MojoClose(MojoHandle handle); |
44 | 44 |
45 // Waits on the given handle until the state indicated by |flags| is satisfied | 45 // Waits on the given handle until a signal indicated by |signals| is satisfied |
46 // or until |deadline| has passed. | 46 // or until |deadline| has passed. |
47 // | 47 // |
48 // Returns: | 48 // Returns: |
49 // |MOJO_RESULT_OK| if some flag in |flags| was satisfied (or is already | 49 // |MOJO_RESULT_OK| if some signal in |signals| was satisfied (or is already |
50 // satisfied). | 50 // satisfied). |
51 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle (e.g., if | 51 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle (e.g., if |
52 // it has already been closed). | 52 // it has already been closed). |
53 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of | 53 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of |
54 // the flags being satisfied. | 54 // the signals being satisfied. |
55 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that any | 55 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that any |
56 // flag in |flags| will ever be satisfied. | 56 // signal in |signals| will ever be satisfied. |
57 // | 57 // |
58 // If there are multiple waiters (on different threads, obviously) waiting on | 58 // If there are multiple waiters (on different threads, obviously) waiting on |
59 // the same handle and flag and that flag becomes set, all waiters will be | 59 // the same handle and signal, and that signal becomes is satisfied, all waiters |
60 // awoken. | 60 // will be awoken. |
61 MOJO_SYSTEM_EXPORT MojoResult MojoWait(MojoHandle handle, | 61 MOJO_SYSTEM_EXPORT MojoResult MojoWait(MojoHandle handle, |
62 MojoWaitFlags flags, | 62 MojoHandleSignals signals, |
63 MojoDeadline deadline); | 63 MojoDeadline deadline); |
64 | 64 |
65 // Waits on |handles[0]|, ..., |handles[num_handles-1]| for at least one of them | 65 // Waits on |handles[0]|, ..., |handles[num_handles-1]| for at least one of them |
66 // to satisfy the state indicated by |flags[0]|, ..., |flags[num_handles-1]|, | 66 // to satisfy a signal indicated by |signals[0]|, ..., |signals[num_handles-1]|, |
67 // respectively, or until |deadline| has passed. | 67 // respectively, or until |deadline| has passed. |
68 // | 68 // |
69 // Returns: | 69 // Returns: |
70 // The index |i| (from 0 to |num_handles-1|) if |handle[i]| satisfies | 70 // The index |i| (from 0 to |num_handles-1|) if |handle[i]| satisfies a signal |
71 // |flags[i]|. | 71 // from |signals[i]|. |
72 // |MOJO_RESULT_INVALID_ARGUMENT| if some |handle[i]| is not a valid handle | 72 // |MOJO_RESULT_INVALID_ARGUMENT| if some |handle[i]| is not a valid handle |
73 // (e.g., if it has already been closed). | 73 // (e.g., if it has already been closed). |
74 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of | 74 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of |
75 // handles satisfying any of its flags. | 75 // handles satisfying any of its signals. |
76 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME | 76 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME |
77 // |handle[i]| will ever satisfy any of its flags |flags[i]|. | 77 // |handle[i]| will ever satisfy any of the signals in |signals[i]|. |
78 MOJO_SYSTEM_EXPORT MojoResult MojoWaitMany(const MojoHandle* handles, | 78 MOJO_SYSTEM_EXPORT MojoResult MojoWaitMany(const MojoHandle* handles, |
79 const MojoWaitFlags* flags, | 79 const MojoHandleSignals* signals, |
80 uint32_t num_handles, | 80 uint32_t num_handles, |
81 MojoDeadline deadline); | 81 MojoDeadline deadline); |
82 | 82 |
83 #ifdef __cplusplus | 83 #ifdef __cplusplus |
84 } // extern "C" | 84 } // extern "C" |
85 #endif | 85 #endif |
86 | 86 |
87 #endif // MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ | 87 #endif // MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ |
OLD | NEW |