blob: 3141212b94d1de2734dfb6de97de000ed9b1df1f [file] [log] [blame]
Vsevolod Tolstopyatov96191342018-04-20 18:13:33 +03001package kotlinx.coroutines.experimental.internal
2
3/**
4 * Special kind of list intended to be used as collection of subscribers in [ArrayBroadcastChannel]
5 * On JVM it's CopyOnWriteList and on JS it's MutableList.
6 *
7 * Note that this alias is intentionally not named as CopyOnWriteList to avoid accidental misusage outside of ArrayBroadcastChannel
8 */
Roman Elizarov11d6b5b2018-04-26 10:11:50 +03009internal typealias SubscribersList<E> = MutableList<E>
Vsevolod Tolstopyatov96191342018-04-20 18:13:33 +030010
Roman Elizarov11d6b5b2018-04-26 10:11:50 +030011internal expect fun <E> subscriberList(): SubscribersList<E>
Vsevolod Tolstopyatov96191342018-04-20 18:13:33 +030012
Roman Elizarov11d6b5b2018-04-26 10:11:50 +030013internal expect class ReentrantLock() {
Vsevolod Tolstopyatov96191342018-04-20 18:13:33 +030014 fun tryLock(): Boolean
15 fun unlock(): Unit
16}
17
Roman Elizarov11d6b5b2018-04-26 10:11:50 +030018internal expect inline fun <T> ReentrantLock.withLock(action: () -> T): T