Created
November 11, 2016 16:41
-
-
Save jpzk/8ad2692dc8b89bc4f8783150c152527d to your computer and use it in GitHub Desktop.
Twitter util time control + MockTimer scheduling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.twitter.util._ | |
import com.twitter.conversions.time._ | |
val timer = new MockTimer() | |
def schedule(timer: Timer) = { | |
timer.schedule(1.second) { | |
println("statement") | |
} | |
} | |
Time.withCurrentTimeFrozen { ctrl => | |
println(Time.now) | |
ctrl.advance(1.second) | |
println(Time.now) | |
timer.tick() | |
schedule(timer) | |
timer.tick() | |
ctrl.advance(1.second) | |
timer.tick() | |
println(Time.now) | |
println("end") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment