TimeUnit
represents time durations at a given unit of granularity and provides utility methods to convert across units, and to perform timing and delay operations in these units. A TimeUnit
does not maintain time information, but only helps organize and use time representations that may be maintained separately across various contexts. More...
Go to the source code of this file.
Enumerations | |
enum | TimeUnit { NanoSeconds = 0, MicroSeconds, MilliSeconds, Seconds } |
Functions | |
static long | doConvert (int delta, long duration) |
long | convert (long duration, TimeUnit fromUnit, TimeUnit toUnit) |
long | toNanos (long duration, TimeUnit fromUnit) |
long | toMicros (long duration, TimeUnit fromUnit) |
long | toMillis (long duration, TimeUnit fromUnit) |
long | toSeconds (long duration, TimeUnit fromUnit) |
Variables | |
module mango locks | TimeUnit |
const int[TimeUnit.max+1] | multipliers |
const long[TimeUnit.max+1] | overflows |
TimeUnit
represents time durations at a given unit of granularity and provides utility methods to convert across units, and to perform timing and delay operations in these units. A TimeUnit
does not maintain time information, but only helps organize and use time representations that may be maintained separately across various contexts.
Written by Doug Lea with assistance from members of JCP JSR-166 Expert Group and released to the public domain, as explained at http://creativecommons.org/licenses/publicdomain Ported to D by Ben Hinkle. Email comments and bug reports to ben.hinkle@gmail.com
revision 2.0
Definition in file TimeUnit.d.
|
Definition at line 44 of file TimeUnit.d. |
|
Perform conversion based on given delta representing the difference between units
Definition at line 78 of file TimeUnit.d. References multipliers, and overflows. Referenced by convert(), toMicros(), toMillis(), toNanos(), and toSeconds(). |
|
Convert the given time duration in the given unit to this unit. Conversions from finer to coarser granularities truncate, so lose precision. For example converting
Definition at line 107 of file TimeUnit.d. References doConvert(). |
|
Convert to nanoseconds.
Definition at line 119 of file TimeUnit.d. References doConvert(). Referenced by Exchanger(), Semaphore::tryAcquire(), ReentrantLock::tryLock(), ReentrantReadWriteLock::WriteLock::tryLock(), ReentrantReadWriteLock::ReadLock::tryLock(), AbstractLock::ConditionObject::wait(), CyclicBarrier::wait(), and CountDownLatch::wait(). |
|
Convert to microseconds.
Definition at line 131 of file TimeUnit.d. References doConvert(), and TimeUnit. |
|
Convert to milliseconds.
Definition at line 143 of file TimeUnit.d. References doConvert(), and TimeUnit. |
|
Convert to seconds.
Definition at line 153 of file TimeUnit.d. References doConvert(), and TimeUnit. |
|
Definition at line 18 of file TimeUnit.d. |
|
Initial value: [ 1, 1000, 1000_000, 1000_000_000 ] Definition at line 52 of file TimeUnit.d. Referenced by doConvert(). |
|
Initial value: [ 0, long.max / 1000, long.max / 1000_000, long.max / 1000_000_000 ] Definition at line 64 of file TimeUnit.d. Referenced by doConvert(). |