July 2018
Intermediate to advanced
266 pages
7h 11m
English
An actor can be buffered, the same as any other send channel. By default, all actors are unbuffered: they suspend the caller on send() until the message has been received. To create a buffered actor you need to pass the capacity parameter to the builder:
fun main(args: Array<String>) { val bufferedPrinter = actor<String>(capacity = 10) { for (msg in channel) { println(msg) } } bufferedPrinter.send("hello") bufferedPrinter.send("world") bufferedPrinter.close()}
Read now
Unlock full access