rust/src/libstd/sys/common
Alex Crichton c6eb8527e0 std: Add Instant and SystemTime to std::time
This commit is an implementation of [RFC 1288][rfc] which adds two new unstable
types to the `std::time` module. The `Instant` type is used to represent
measurements of a monotonically increasing clock suitable for measuring time
withing a process for operations such as benchmarks or just the elapsed time to
do something. An `Instant` favors panicking when bugs are found as the bugs are
programmer errors rather than typical errors that can be encountered.

[rfc]: https://github.com/rust-lang/rfcs/pull/1288

The `SystemTime` type is used to represent a system timestamp and is not
monotonic. Very few guarantees are provided about this measurement of the system
clock, but a fixed point in time (`UNIX_EPOCH`) is provided to learn about the
relative distance from this point for any particular time stamp.

This PR takes the same implementation strategy as the `time` crate on crates.io,
namely:

|  Platform  |  Instant                 |  SystemTime              |
|------------|--------------------------|--------------------------|
| Windows    | QueryPerformanceCounter  | GetSystemTimeAsFileTime  |
| OSX        | mach_absolute_time       | gettimeofday             |
| Unix       | CLOCK_MONOTONIC          | CLOCK_REALTIME           |

These implementations can perhaps be refined over time, but they currently
satisfy the requirements of the `Instant` and `SystemTime` types while also
being portable across implementations and revisions of each platform.
2015-11-19 09:32:38 -08:00
..
dwarf std: Internalize almost all of std::rt 2015-09-11 11:19:20 -07:00
gnu some more clippy-based improvements 2015-09-08 00:36:29 +02:00
unwind Fix buildbot failures 2015-11-18 21:16:20 +03:00
args.rs std: Internalize almost all of std::rt 2015-09-11 11:19:20 -07:00
at_exit_imp.rs std: Internalize almost all of std::rt 2015-09-11 11:19:20 -07:00
backtrace.rs Port the standard crates to PNaCl/NaCl. 2015-10-28 17:23:28 -05:00
condvar.rs Use const fn to abstract away the contents of UnsafeCell & friends. 2015-05-27 11:19:03 +03:00
io.rs Add specializations of read_to_end for Stdin, TcpStream and File, 2015-07-15 21:30:18 +01:00
libunwind.rs Fix stage0 ICE caused by the old _Unwind_Resume override trickery. 2015-10-31 18:52:37 -07:00
mod.rs std: Add Instant and SystemTime to std::time 2015-11-19 09:32:38 -08:00
mutex.rs Use const fn to abstract away the contents of UnsafeCell & friends. 2015-05-27 11:19:03 +03:00
net.rs std: Migrate to the new libc 2015-11-09 22:55:50 -08:00
poison.rs Add missing annotations and some tests 2015-11-18 01:24:21 +03:00
remutex.rs some more clippy-based improvements 2015-09-08 00:36:29 +02:00
rwlock.rs Use const fn to abstract away the contents of UnsafeCell & friends. 2015-05-27 11:19:03 +03:00
thread.rs Remove morestack support 2015-08-10 16:35:44 -07:00
thread_info.rs Register new snapshots 2015-08-11 15:11:13 -07:00
thread_local.rs std: Add issues to all unstable features 2015-08-15 18:09:17 -07:00
util.rs std: Internalize almost all of std::rt 2015-09-11 11:19:20 -07:00
wtf8.rs Add missing annotations and some tests 2015-11-18 01:24:21 +03:00