diff options
author | Roman Elizarov <elizarov@gmail.com> | 2019-07-02 16:59:22 +0300 |
---|---|---|
committer | Roman Elizarov <elizarov@gmail.com> | 2019-07-03 14:51:32 +0300 |
commit | 96a5c8e3337f86e46d2cad7af4b9c000506a7121 (patch) | |
tree | 4cd17b95d9e3531d5df757c54d8338050eb8c6eb /kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt | |
parent | fa9104e4e89514f361f14488c475d6a2c98257df (diff) | |
download | platform_external_kotlinx.coroutines-96a5c8e3337f86e46d2cad7af4b9c000506a7121.tar.gz platform_external_kotlinx.coroutines-96a5c8e3337f86e46d2cad7af4b9c000506a7121.tar.bz2 platform_external_kotlinx.coroutines-96a5c8e3337f86e46d2cad7af4b9c000506a7121.zip |
Optimize virtual time source so that DefaultTimeSource is not needed
* Default implementation is "null" reference to time-source which
avoids the need for interface call in default case.
Diffstat (limited to 'kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt')
-rw-r--r-- | kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt index bebb94b1..8c1e3f83 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt @@ -1,5 +1,5 @@ /* - * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ // This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. @@ -9,13 +9,13 @@ import kotlinx.coroutines.* fun main() = runBlocking { //sampleStart - val startTime = timeSource.currentTimeMillis() + val startTime = currentTimeMillis() val job = launch(Dispatchers.Default) { var nextPrintTime = startTime var i = 0 while (isActive) { // cancellable computation loop // print a message twice a second - if (timeSource.currentTimeMillis() >= nextPrintTime) { + if (currentTimeMillis() >= nextPrintTime) { println("job: I'm sleeping ${i++} ...") nextPrintTime += 500L } |