1 /* <lambda>null2 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5 // This file was automatically generated from flow.md by Knit tool. Do not edit. 6 package kotlinx.coroutines.guide.exampleFlow17 7 8 import kotlinx.coroutines.* 9 import kotlinx.coroutines.flow.* 10 import kotlin.system.* 11 12 fun simple(): Flow<Int> = flow { 13 for (i in 1..3) { 14 delay(100) // pretend we are asynchronously waiting 100 ms 15 emit(i) // emit next value 16 } 17 } 18 <lambda>null19fun main() = runBlocking<Unit> { 20 val time = measureTimeMillis { 21 simple() 22 .buffer() // buffer emissions, don't wait 23 .collect { value -> 24 delay(300) // pretend we are processing it for 300 ms 25 println(value) 26 } 27 } 28 println("Collected in $time ms") 29 } 30