| 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_ |
| 11 | 11 |
| 12 #include "mojo/public/c/system/system_export.h" | |
| 13 #include "mojo/public/c/system/types.h" | 12 #include "mojo/public/c/system/types.h" |
| 14 | 13 |
| 15 #ifdef __cplusplus | 14 #ifdef __cplusplus |
| 16 extern "C" { | 15 extern "C" { |
| 17 #endif | 16 #endif |
| 18 | 17 |
| 19 // Note: Pointer parameters that are labelled "optional" may be null (at least | 18 // Note: Pointer parameters that are labelled "optional" may be null (at least |
| 20 // under some circumstances). Non-const pointer parameters are also labeled | 19 // under some circumstances). Non-const pointer parameters are also labeled |
| 21 // "in", "out", or "in/out", to indicate how they are used. (Note that how/if | 20 // "in", "out", or "in/out", to indicate how they are used. (Note that how/if |
| 22 // such a parameter is used may depend on other parameters or the requested | 21 // such a parameter is used may depend on other parameters or the requested |
| 23 // operation's success/failure. E.g., a separate |flags| parameter may control | 22 // operation's success/failure. E.g., a separate |flags| parameter may control |
| 24 // whether a given "in/out" parameter is used for input, output, or both.) | 23 // whether a given "in/out" parameter is used for input, output, or both.) |
| 25 | 24 |
| 26 // Returns the time, in microseconds, since some undefined point in the past. | 25 // Returns the time, in microseconds, since some undefined point in the past. |
| 27 // The values are only meaningful relative to other values that were obtained | 26 // The values are only meaningful relative to other values that were obtained |
| 28 // from the same device without an intervening system restart. Such values are | 27 // from the same device without an intervening system restart. Such values are |
| 29 // guaranteed to be monotonically non-decreasing with the passage of real time. | 28 // guaranteed to be monotonically non-decreasing with the passage of real time. |
| 30 // Although the units are microseconds, the resolution of the clock may vary and | 29 // Although the units are microseconds, the resolution of the clock may vary and |
| 31 // is typically in the range of ~1-15 ms. | 30 // is typically in the range of ~1-15 ms. |
| 32 MOJO_SYSTEM_EXPORT MojoTimeTicks MojoGetTimeTicksNow(void); | 31 MojoTimeTicks MojoGetTimeTicksNow(void); |
| 33 | 32 |
| 34 // Closes the given |handle|. | 33 // Closes the given |handle|. |
| 35 // | 34 // |
| 36 // Returns: | 35 // Returns: |
| 37 // |MOJO_RESULT_OK| on success. | 36 // |MOJO_RESULT_OK| on success. |
| 38 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. | 37 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. |
| 39 // | 38 // |
| 40 // 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 |
| 41 // 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 |
| 42 // 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 |
| 43 // fail with |MOJO_RESULT_INVALID_ARGUMENT| if they happen after. | 42 // fail with |MOJO_RESULT_INVALID_ARGUMENT| if they happen after. |
| 44 MOJO_SYSTEM_EXPORT MojoResult MojoClose(MojoHandle handle); | 43 MojoResult MojoClose(MojoHandle handle); |
| 45 | 44 |
| 46 // Waits on the given handle until one of the following happens: | 45 // Waits on the given handle until one of the following happens: |
| 47 // - A signal indicated by |signals| is satisfied. | 46 // - A signal indicated by |signals| is satisfied. |
| 48 // - It becomes known that no signal indicated by |signals| will ever be | 47 // - It becomes known that no signal indicated by |signals| will ever be |
| 49 // satisfied. (See the description of the |MOJO_RESULT_CANCELLED| and | 48 // satisfied. (See the description of the |MOJO_RESULT_CANCELLED| and |
| 50 // |MOJO_RESULT_FAILED_PRECONDITION| return values below.) | 49 // |MOJO_RESULT_FAILED_PRECONDITION| return values below.) |
| 51 // - Until |deadline| has passed. | 50 // - Until |deadline| has passed. |
| 52 // | 51 // |
| 53 // If |deadline| is |MOJO_DEADLINE_INDEFINITE|, this will wait "forever" (until | 52 // If |deadline| is |MOJO_DEADLINE_INDEFINITE|, this will wait "forever" (until |
| 54 // one of the other wait termination conditions is satisfied). If |deadline| is | 53 // one of the other wait termination conditions is satisfied). If |deadline| is |
| (...skipping 12 matching lines...) Expand all Loading... |
| 67 // it has already been closed). The |signals_state| value is unchanged. | 66 // it has already been closed). The |signals_state| value is unchanged. |
| 68 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of | 67 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of |
| 69 // the signals being satisfied. | 68 // the signals being satisfied. |
| 70 // |MOJO_RESULT_FAILED_PRECONDITION| if it becomes known that none of the | 69 // |MOJO_RESULT_FAILED_PRECONDITION| if it becomes known that none of the |
| 71 // signals in |signals| can ever be satisfied (e.g., when waiting on one | 70 // signals in |signals| can ever be satisfied (e.g., when waiting on one |
| 72 // end of a message pipe and the other end is closed). | 71 // end of a message pipe and the other end is closed). |
| 73 // | 72 // |
| 74 // If there are multiple waiters (on different threads, obviously) waiting on | 73 // If there are multiple waiters (on different threads, obviously) waiting on |
| 75 // the same handle and signal, and that signal becomes satisfied, all waiters | 74 // the same handle and signal, and that signal becomes satisfied, all waiters |
| 76 // will be awoken. | 75 // will be awoken. |
| 77 MOJO_SYSTEM_EXPORT MojoResult | 76 MojoResult MojoWait( |
| 78 MojoWait(MojoHandle handle, | 77 MojoHandle handle, |
| 79 MojoHandleSignals signals, | 78 MojoHandleSignals signals, |
| 80 MojoDeadline deadline, | 79 MojoDeadline deadline, |
| 81 struct MojoHandleSignalsState* signals_state); // Optional out. | 80 struct MojoHandleSignalsState* signals_state); // Optional out. |
| 82 | 81 |
| 83 // Waits on |handles[0]|, ..., |handles[num_handles-1]| until: | 82 // Waits on |handles[0]|, ..., |handles[num_handles-1]| until: |
| 84 // - (At least) one handle satisfies a signal indicated in its respective | 83 // - (At least) one handle satisfies a signal indicated in its respective |
| 85 // |signals[0]|, ..., |signals[num_handles-1]|. | 84 // |signals[0]|, ..., |signals[num_handles-1]|. |
| 86 // - It becomes known that no signal in some |signals[i]| will ever be | 85 // - It becomes known that no signal in some |signals[i]| will ever be |
| 87 // satisfied. | 86 // satisfied. |
| 88 // - |deadline| has passed. | 87 // - |deadline| has passed. |
| 89 // | 88 // |
| 90 // This means that |MojoWaitMany()| behaves as if |MojoWait()| were called on | 89 // This means that |MojoWaitMany()| behaves as if |MojoWait()| were called on |
| 91 // each handle/signals pair simultaneously, completing when the first | 90 // each handle/signals pair simultaneously, completing when the first |
| (...skipping 20 matching lines...) Expand all Loading... |
| 112 // another thread) during the wait. | 111 // another thread) during the wait. |
| 113 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if there are too many handles. The | 112 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if there are too many handles. The |
| 114 // |signals_state| array is unchanged. | 113 // |signals_state| array is unchanged. |
| 115 // |MOJO_RESULT_INVALID_ARGUMENT| if some |handle[i]| is not a valid handle | 114 // |MOJO_RESULT_INVALID_ARGUMENT| if some |handle[i]| is not a valid handle |
| 116 // (e.g., if it is zero or if it has already been closed). The | 115 // (e.g., if it is zero or if it has already been closed). The |
| 117 // |signals_state| array is unchanged. | 116 // |signals_state| array is unchanged. |
| 118 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of | 117 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of |
| 119 // handles satisfying any of its signals. | 118 // handles satisfying any of its signals. |
| 120 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME | 119 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME |
| 121 // |handle[i]| will ever satisfy any of the signals in |signals[i]|. | 120 // |handle[i]| will ever satisfy any of the signals in |signals[i]|. |
| 122 MOJO_SYSTEM_EXPORT MojoResult | 121 MojoResult MojoWaitMany( |
| 123 MojoWaitMany(const MojoHandle* handles, | 122 const MojoHandle* handles, |
| 124 const MojoHandleSignals* signals, | 123 const MojoHandleSignals* signals, |
| 125 uint32_t num_handles, | 124 uint32_t num_handles, |
| 126 MojoDeadline deadline, | 125 MojoDeadline deadline, |
| 127 uint32_t* result_index, // Optional out | 126 uint32_t* result_index, // Optional out |
| 128 struct MojoHandleSignalsState* signals_states); // Optional out | 127 struct MojoHandleSignalsState* signals_states); // Optional out |
| 129 | 128 |
| 130 #ifdef __cplusplus | 129 #ifdef __cplusplus |
| 131 } // extern "C" | 130 } // extern "C" |
| 132 #endif | 131 #endif |
| 133 | 132 |
| 134 #endif // MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ | 133 #endif // MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ |
| OLD | NEW |