| OLD | NEW |
| 1 // Copyright 2014 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 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_WAIT_H_ |
| 10 #define MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ | 10 #define MOJO_PUBLIC_C_SYSTEM_WAIT_H_ |
| 11 | 11 |
| 12 #include "mojo/public/c/system/handle.h" | 12 #include "mojo/public/c/system/handle.h" |
| 13 #include "mojo/public/c/system/result.h" | 13 #include "mojo/public/c/system/result.h" |
| 14 #include "mojo/public/c/system/types.h" | 14 #include "mojo/public/c/system/time.h" |
| 15 | 15 |
| 16 #ifdef __cplusplus | 16 #ifdef __cplusplus |
| 17 extern "C" { | 17 extern "C" { |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 // Note: Pointer parameters that are labelled "optional" may be null (at least | |
| 21 // under some circumstances). Non-const pointer parameters are also labeled | |
| 22 // "in", "out", or "in/out", to indicate how they are used. (Note that how/if | |
| 23 // such a parameter is used may depend on other parameters or the requested | |
| 24 // operation's success/failure. E.g., a separate |flags| parameter may control | |
| 25 // whether a given "in/out" parameter is used for input, output, or both.) | |
| 26 | |
| 27 // Returns the time, in microseconds, since some undefined point in the past. | |
| 28 // The values are only meaningful relative to other values that were obtained | |
| 29 // from the same device without an intervening system restart. Such values are | |
| 30 // guaranteed to be monotonically non-decreasing with the passage of real time. | |
| 31 // Although the units are microseconds, the resolution of the clock may vary and | |
| 32 // is typically in the range of ~1-15 ms. | |
| 33 MojoTimeTicks MojoGetTimeTicksNow(void); | |
| 34 | |
| 35 // Closes the given |handle|. | |
| 36 // | |
| 37 // Returns: | |
| 38 // |MOJO_RESULT_OK| on success. | |
| 39 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. | |
| 40 // | |
| 41 // Concurrent operations on |handle| may succeed (or fail as usual) if they | |
| 42 // happen before the close, be cancelled with result |MOJO_RESULT_CANCELLED| if | |
| 43 // they properly overlap (this is likely the case with |MojoWait()|, etc.), or | |
| 44 // fail with |MOJO_RESULT_INVALID_ARGUMENT| if they happen after. | |
| 45 MojoResult MojoClose(MojoHandle handle); | |
| 46 | |
| 47 // Waits on the given handle until one of the following happens: | 20 // Waits on the given handle until one of the following happens: |
| 48 // - A signal indicated by |signals| is satisfied. | 21 // - A signal indicated by |signals| is satisfied. |
| 49 // - It becomes known that no signal indicated by |signals| will ever be | 22 // - It becomes known that no signal indicated by |signals| will ever be |
| 50 // satisfied. (See the description of the |MOJO_RESULT_CANCELLED| and | 23 // satisfied. (See the description of the |MOJO_RESULT_CANCELLED| and |
| 51 // |MOJO_RESULT_FAILED_PRECONDITION| return values below.) | 24 // |MOJO_RESULT_FAILED_PRECONDITION| return values below.) |
| 52 // - Until |deadline| has passed. | 25 // - Until |deadline| has passed. |
| 53 // | 26 // |
| 54 // If |deadline| is |MOJO_DEADLINE_INDEFINITE|, this will wait "forever" (until | 27 // If |deadline| is |MOJO_DEADLINE_INDEFINITE|, this will wait "forever" (until |
| 55 // one of the other wait termination conditions is satisfied). If |deadline| is | 28 // one of the other wait termination conditions is satisfied). If |deadline| is |
| 56 // 0, this will return |MOJO_RESULT_DEADLINE_EXCEEDED| only if one of the other | 29 // 0, this will return |MOJO_RESULT_DEADLINE_EXCEEDED| only if one of the other |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 const MojoHandleSignals* signals, | 98 const MojoHandleSignals* signals, |
| 126 uint32_t num_handles, | 99 uint32_t num_handles, |
| 127 MojoDeadline deadline, | 100 MojoDeadline deadline, |
| 128 uint32_t* result_index, // Optional out | 101 uint32_t* result_index, // Optional out |
| 129 struct MojoHandleSignalsState* signals_states); // Optional out | 102 struct MojoHandleSignalsState* signals_states); // Optional out |
| 130 | 103 |
| 131 #ifdef __cplusplus | 104 #ifdef __cplusplus |
| 132 } // extern "C" | 105 } // extern "C" |
| 133 #endif | 106 #endif |
| 134 | 107 |
| 135 #endif // MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ | 108 #endif // MOJO_PUBLIC_C_SYSTEM_WAIT_H_ |
| OLD | NEW |