about summary refs log tree commit diff
path: root/src/libstd/time/mod.rs
AgeCommit message (Collapse)AuthorLines
2016-05-12Use the correct word in the explanationStefan Schindler-1/+1
2016-03-26Rollup merge of #32448 - sfackler:time-augmented-assignment, r=alexcrichtonManish Goregaokar-1/+29
Add augmented assignment operator impls for time types r? @alexcrichton
2016-03-23Add code examples for libstd/timeGuillaume Gomez-0/+50
2016-03-22Add augmented assignment operator impls for time typesSteven Fackler-1/+29
2016-02-29std: Stabilize APIs for the 1.8 releaseAlex Crichton-27/+55
This commit is the result of the FCPs ending for the 1.8 release cycle for both the libs and the lang suteams. The full list of changes are: Stabilized * `braced_empty_structs` * `augmented_assignments` * `str::encode_utf16` - renamed from `utf16_units` * `str::EncodeUtf16` - renamed from `Utf16Units` * `Ref::map` * `RefMut::map` * `ptr::drop_in_place` * `time::Instant` * `time::SystemTime` * `{Instant,SystemTime}::now` * `{Instant,SystemTime}::duration_since` - renamed from `duration_from_earlier` * `{Instant,SystemTime}::elapsed` * Various `Add`/`Sub` impls for `Time` and `SystemTime` * `SystemTimeError` * `SystemTimeError::duration` * Various impls for `SystemTimeError` * `UNIX_EPOCH` * `ops::{Add,Sub,Mul,Div,Rem,BitAnd,BitOr,BitXor,Shl,Shr}Assign` Deprecated * Scoped TLS (the `scoped_thread_local!` macro) * `Ref::filter_map` * `RefMut::filter_map` * `RwLockReadGuard::map` * `RwLockWriteGuard::map` * `Condvar::wait_timeout_with` Closes #27714 Closes #27715 Closes #27746 Closes #27748 Closes #27908 Closes #29866
2016-02-04std: Expose SystemTime accessors on fs::MetadataAlex Crichton-0/+7
These accessors are used to get at the last modification, last access, and creation time of the underlying file. Currently not all platforms provide the creation time, so that currently returns `Option`.
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.