Astronaut4449
02/19/2020, 6:55 PMChannel
constructor takes a capacity
argument of type Int. capacity
is also used to define the type of the channel by the use of magic constants such as RENDEVOUS=0, BUFFERED=-2, UNLIMITED=Int.MAX_VALUE.
val c1 = Channel<Int>(capacity = 15)
val c2 = Channel<Int>(capacity = RENDEVOUS) // dislike
Kotlin has the great feature of sealed classes. Wouldn't it be better to have an API like:
// Limited(capacity: Int) and object Rendevous belong to sealed class ChannelType
val c1 = Channel<Int>(type = Limited(15))
val c2 = Channel<Int>(type = Rendevous) // Rendevous is an object here
Astronaut4449
03/05/2020, 4:22 PMelizarov
03/05/2020, 4:25 PMelizarov
03/05/2020, 4:28 PM