summary refs log tree commit diff
path: root/src/libstd/time/mod.rs
AgeCommit message (Collapse)AuthorLines
2016-01-12Update wording of Instant and SystemTime docsSimon Sapin-4/+4
… per aturon’s proposal.
2015-12-28Instant/SystemTime doc: add meaning to first lineSimon Sapin-3/+4
The first line (paragraph?) of a doc-comment is what rustdoc shows when listing items of a module. What makes `Instant` and `SystemTime` different is important enough to be there. (Though feel free to bikeshed the wording.)
2015-12-03Fix tests for SystemTime addition on mac and iosSean Griffin-2/+2
Those platforms don't support nanosecond precision, so adding 1 nanosecond does nothing.
2015-12-02Fixed make tidy errorSean Griffin-1/+2
2015-12-02Ensure two `SystemTime`s are equal when nanos add to exactly 1BSean Griffin-0/+4
Currently if you add a duration which should lead to 0 nanos and 1 additional second, we end up with no additional seconds, and 1000000000 nanos.
2015-11-30std: Bump time margin in std::time testsAlex Crichton-1/+1
I believe that because Windows' unit of resolution is 100ns that this unit of time will ensure that the assertions will hold true as it's representable in the native format. cc #29970
2015-11-26doc: this is already mentioned in previous paragraph, and is harder to readTshepang Lekhonkhobe-3/+2
2015-11-25doc: fix type nameTshepang Lekhonkhobe-1/+1
2015-11-25doc: add a pauseTshepang Lekhonkhobe-2/+3
2015-11-25doc: split overlong sentenceTshepang Lekhonkhobe-2/+2
2015-11-25doc: add missing commasTshepang Lekhonkhobe-2/+2
2015-11-25doc: fix grammarTshepang Lekhonkhobe-1/+1
2015-11-25doc: remove info repeated on next paragraphTshepang Lekhonkhobe-2/+1
2015-11-23std: Tweak tests of std::timeAlex Crichton-14/+24
Typical algebra currently doesn't work on the types in std::time currently (see [this comment][comment]), so tweak the tests to account for this property. [comment]: https://github.com/rust-lang/rust/issues/29866#issuecomment-159093809 Closes #29970
2015-11-19std: Add Instant and SystemTime to std::timeAlex Crichton-0/+304
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-18Add missing annotations and some testsVadim Petrochenkov-0/+1
2015-08-10Stabilize the Duration APISteven Fackler-1/+1
This commit stabilizes the `std::time` module and the `Duration` type. `Duration::span` remains unstable, and the `Display` implementation for `Duration` has been removed as it is still being reworked and all trait implementations for stable types are de facto stable. This is a [breaking-change] to those using `Duration`'s `Display` implementation.
2015-05-13std: Redesign Duration, implementing RFC 1040Alex Crichton-11/+2
This commit is an implementation of [RFC 1040][rfc] which is a redesign of the currently-unstable `Duration` type. The API of the type has been scaled back to be more conservative and it also no longer supports negative durations. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1040-duration-reform.md The inner `duration` module of the `time` module has now been hidden (as `Duration` is reexported) and the feature name for this type has changed from `std_misc` to `duration`. All APIs accepting durations have also been audited to take a more flavorful feature name instead of `std_misc`. Closes #24874
2015-01-30Add a few missing stability markers.Chris Morgan-0/+2
2015-01-16Rewrite Condvar::wait_timeout and make it publicSteven Fackler-66/+2
**The implementation is a direct adaptation of libcxx's condition_variable implementation.** pthread_cond_timedwait uses the non-monotonic system clock. It's possible to change the clock to a monotonic via pthread_cond_attr, but this is incompatible with static initialization. To deal with this, we calculate the timeout using the system clock, and maintain a separate record of the start and end times with a monotonic clock to be used for calculation of the return value.
2015-01-01std: Second pass stabilization of syncAlex Crichton-1/+1
This pass performs a second pass of stabilization through the `std::sync` module, avoiding modules/types that are being handled in other PRs (e.g. mutexes, rwlocks, condvars, and channels). The following items are now stable * `sync::atomic` * `sync::atomic::ATOMIC_BOOL_INIT` (was `INIT_ATOMIC_BOOL`) * `sync::atomic::ATOMIC_INT_INIT` (was `INIT_ATOMIC_INT`) * `sync::atomic::ATOMIC_UINT_INIT` (was `INIT_ATOMIC_UINT`) * `sync::Once` * `sync::ONCE_INIT` * `sync::Once::call_once` (was `doit`) * C == `pthread_once(..)` * Boost == `call_once(..)` * Windows == `InitOnceExecuteOnce` * `sync::Barrier` * `sync::Barrier::new` * `sync::Barrier::wait` (now returns a `bool`) * `sync::Semaphore::new` * `sync::Semaphore::acquire` * `sync::Semaphore::release` The following items remain unstable * `sync::SemaphoreGuard` * `sync::Semaphore::access` - it's unclear how this relates to the poisoning story of mutexes. * `sync::TaskPool` - the semantics of a failing task and whether a thread is re-attached to a thread pool are somewhat unclear, and the utility of this type in `sync` is question with respect to the jobs of other primitives. This type will likely become stable or move out of the standard library over time. * `sync::Future` - futures as-is have yet to be deeply re-evaluated with the recent core changes to Rust's synchronization story, and will likely become stable in the future but are unstable until that time comes. [breaking-change]
2014-11-12time: Deprecate the library in the distributionAlex Crichton-0/+73
This commit deprecates the entire libtime library in favor of the externally-provided libtime in the rust-lang organization. Users of the `libtime` crate as-is today should add this to their Cargo manifests: [dependencies.time] git = "https://github.com/rust-lang/time" To implement this transition, a new function `Duration::span` was added to the `std::time::Duration` time. This function takes a closure and then returns the duration of time it took that closure to execute. This interface will likely improve with `FnOnce` unboxed closures as moving in and out will be a little easier. Due to the deprecation of the in-tree crate, this is a: [breaking-change] cc #18855, some of the conversions in the `src/test/bench` area may have been a little nicer with that implemented
2014-08-13std: Refactor time module a bitBrian Anderson-0/+15
Put `Duration` in `time::duration`, where the two constants can be called just `MAX` and `MIN`. Reexport from `time`. This provides more room for the time module to expand.