blob: d5ae3f1544e0fb09397b5c05714039c5b5b2b20b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package scala.concurrent.util
import java.util.concurrent.TimeUnit
import scala.language.implicitConversions
package object duration {
object span
implicit object spanConvert extends Classifier[span.type] {
type R = FiniteDuration
def convert(d: FiniteDuration) = d
}
object fromNow
implicit object fromNowConvert extends Classifier[fromNow.type] {
type R = Deadline
def convert(d: FiniteDuration) = Deadline.now + d
}
implicit def intToDurationInt(n: Int) = new DurationInt(n)
implicit def longToDurationLong(n: Long) = new DurationLong(n)
implicit def doubleToDurationDouble(d: Double) = new DurationDouble(d)
implicit def pairIntToDuration(p: (Int, TimeUnit)) = Duration(p._1, p._2)
implicit def pairLongToDuration(p: (Long, TimeUnit)) = Duration(p._1, p._2)
implicit def durationToPair(d: Duration) = (d.length, d.unit)
implicit def intMult(i: Int) = new IntMult(i)
implicit def longMult(l: Long) = new LongMult(l)
implicit def doubleMult(f: Double) = new DoubleMult(f)
}
|