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_ |
| 11 | 11 |
| 12 // Note: This header should be compilable as C. | |
| 13 | |
| 14 #include "mojo/public/c/system/system_export.h" | 12 #include "mojo/public/c/system/system_export.h" |
| 15 #include "mojo/public/c/system/types.h" | 13 #include "mojo/public/c/system/types.h" |
| 16 | 14 |
| 17 #ifdef __cplusplus | 15 #ifdef __cplusplus |
| 18 extern "C" { | 16 extern "C" { |
| 19 #endif | 17 #endif |
| 20 | 18 |
| 21 // Note: Pointer parameters that are labelled "optional" may be null (at least | 19 // Note: Pointer parameters that are labelled "optional" may be null (at least |
| 22 // under some circumstances). Non-const pointer parameters are also labeled | 20 // under some circumstances). Non-const pointer parameters are also labeled |
| 23 // "in", "out", or "in/out", to indicate how they are used. (Note that how/if | 21 // "in", "out", or "in/out", to indicate how they are used. (Note that how/if |
| 24 // such a parameter is used may depend on other parameters or the requested | 22 // such a parameter is used may depend on other parameters or the requested |
| 25 // operation's success/failure. E.g., a separate |flags| parameter may control | 23 // operation's success/failure. E.g., a separate |flags| parameter may control |
| 26 // whether a given "in/out" parameter is used for input, output, or both.) | 24 // whether a given "in/out" parameter is used for input, output, or both.) |
| 27 | 25 |
| 28 // Platform-dependent monotonically increasing tick count representing "right | 26 // Returns the amount of time, in units of microseconds, that has passed since |
|
viettrungluu
2015/01/30 22:34:17
Generally, this is overly verbose.
ggowan
2015/01/30 23:17:12
OK, I made it shorter.
| |
| 29 // now." The resolution of this clock is ~1-15ms. Resolution varies depending | 27 // some undefined point in the past. The values are only meaningful relative to |
| 30 // on hardware/operating system configuration. | 28 // other values obtained from the same device without an intervening system |
| 29 // restart. Such values are guaranteed to be weakly monotonically-increasing | |
| 30 // with the passage of real time, meaning they will not always advance, but they | |
| 31 // will never go backwards (unlike time values with a well-defined epoch). | |
|
viettrungluu
2015/01/30 22:34:17
As far as I know, time travel is still an impossib
ggowan
2015/01/30 23:17:12
If you're talking about a value obtained from a cl
| |
| 32 // Although the units are microseconds, the values should not be assumed to be | |
| 33 // at that level of precision. The actual precision varies depending on hardware | |
| 34 // and platform, and is typically in the range of ~1-15 ms. | |
| 31 MOJO_SYSTEM_EXPORT MojoTimeTicks MojoGetTimeTicksNow(void); | 35 MOJO_SYSTEM_EXPORT MojoTimeTicks MojoGetTimeTicksNow(void); |
| 32 | 36 |
| 33 // Closes the given |handle|. | 37 // Closes the given |handle|. |
| 34 // | 38 // |
| 35 // Returns: | 39 // Returns: |
| 36 // |MOJO_RESULT_OK| on success. | 40 // |MOJO_RESULT_OK| on success. |
| 37 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. | 41 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. |
| 38 // | 42 // |
| 39 // Concurrent operations on |handle| may succeed (or fail as usual) if they | 43 // 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 | 44 // happen before the close, be cancelled with result |MOJO_RESULT_CANCELLED| if |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 64 // thread) during the wait. | 68 // thread) during the wait. |
| 65 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle (e.g., if | 69 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle (e.g., if |
| 66 // it has already been closed). The |signals_state| value is unchanged. | 70 // it has already been closed). The |signals_state| value is unchanged. |
| 67 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of | 71 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of |
| 68 // the signals being satisfied. | 72 // the signals being satisfied. |
| 69 // |MOJO_RESULT_FAILED_PRECONDITION| if it becomes known that none of the | 73 // |MOJO_RESULT_FAILED_PRECONDITION| if it becomes known that none of the |
| 70 // signals in |signals| can ever be satisfied (e.g., when waiting on one | 74 // signals in |signals| can ever be satisfied (e.g., when waiting on one |
| 71 // end of a message pipe and the other end is closed). | 75 // end of a message pipe and the other end is closed). |
| 72 // | 76 // |
| 73 // If there are multiple waiters (on different threads, obviously) waiting on | 77 // If there are multiple waiters (on different threads, obviously) waiting on |
| 74 // the same handle and signal, and that signal becomes is satisfied, all waiters | 78 // the same handle and signal, and that signal becomes satisfied, all waiters |
| 75 // will be awoken. | 79 // will be awoken. |
| 76 MOJO_SYSTEM_EXPORT MojoResult | 80 MOJO_SYSTEM_EXPORT MojoResult |
| 77 MojoWait(MojoHandle handle, | 81 MojoWait(MojoHandle handle, |
| 78 MojoHandleSignals signals, | 82 MojoHandleSignals signals, |
| 79 MojoDeadline deadline, | 83 MojoDeadline deadline, |
| 80 struct MojoHandleSignalsState* signals_state); // Optional out. | 84 struct MojoHandleSignalsState* signals_state); // Optional out. |
| 81 | 85 |
| 82 // Waits on |handles[0]|, ..., |handles[num_handles-1]| until: | 86 // Waits on |handles[0]|, ..., |handles[num_handles-1]| until: |
| 83 // - (At least) one handle satisfies a signal indicated in its respective | 87 // - (At least) one handle satisfies a signal indicated in its respective |
| 84 // |signals[0]|, ..., |signals[num_handles-1]|. | 88 // |signals[0]|, ..., |signals[num_handles-1]|. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 uint32_t num_handles, | 128 uint32_t num_handles, |
| 125 MojoDeadline deadline, | 129 MojoDeadline deadline, |
| 126 uint32_t* result_index, // Optional out | 130 uint32_t* result_index, // Optional out |
| 127 struct MojoHandleSignalsState* signals_states); // Optional out | 131 struct MojoHandleSignalsState* signals_states); // Optional out |
| 128 | 132 |
| 129 #ifdef __cplusplus | 133 #ifdef __cplusplus |
| 130 } // extern "C" | 134 } // extern "C" |
| 131 #endif | 135 #endif |
| 132 | 136 |
| 133 #endif // MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ | 137 #endif // MOJO_PUBLIC_C_SYSTEM_FUNCTIONS_H_ |
| OLD | NEW |