Skip to content

Commit

Permalink
Use launch instead of async
Browse files Browse the repository at this point in the history
  • Loading branch information
tygern committed Apr 14, 2024
1 parent 05e3407 commit c1390e3
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package test.initialcapacity.streaming.waitfor
import io.initialcapacity.streaming.waitfor.waitFor
import kotlinx.coroutines.async
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import java.io.Writer
import kotlin.test.Test
Expand All @@ -16,10 +17,10 @@ class WaitForTest {
val writer = TestWriter()

writer.write("Start")
val waited = async { writer.write(writer.waitFor(message)) }
val waited = launch { writer.write(writer.waitFor(message)) }

messages.send("End")
waited.await()
waited.join()
assertEquals(listOf("Start", "flush", "End"), writer.actions)
}
}
Expand Down

0 comments on commit c1390e3

Please sign in to comment.