about summary refs log tree commit diff
path: root/src/liballoc_system
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-11-19 23:57:07 +0000
committerbors <bors@rust-lang.org>2015-11-19 23:57:07 +0000
commitb289892b5d4acd52237fb88ab12f825e7602280c (patch)
tree82332c0640871d8d6d3df3c9e58d11c904fa2cd4 /src/liballoc_system
parent6861c51453963317849b4488ddc6a110e4f3470a (diff)
parentc6eb8527e09bed702f30ffdc8d6e54acf9b867ca (diff)
downloadrust-b289892b5d4acd52237fb88ab12f825e7602280c.tar.gz
rust-b289892b5d4acd52237fb88ab12f825e7602280c.zip
Auto merge of #29894 - alexcrichton:stdtime, r=brson
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.

cc #29866
Diffstat (limited to 'src/liballoc_system')
0 files changed, 0 insertions, 0 deletions