This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ru.tetraquark.kotlin.playground.shared.eventbus.EventBus | |
import kotlin.native.concurrent.TransferMode | |
import kotlin.native.concurrent.Worker | |
import kotlin.native.concurrent.freeze | |
class RefHolder<T>(ref: T?) { | |
var ref: T? = ref | |
get() { | |
val tmp = field | |
ref = null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.atomicfu.atomic | |
import kotlinx.atomicfu.getAndUpdate | |
import kotlin.reflect.KClass | |
typealias Observer = (Any) -> Unit | |
object EventBus { | |
private val observers = atomic(mutableMapOf<KClass<out Any>, List<Observer>>()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl --location --request POST 'https://fcm.googleapis.com/fcm/send' \ | |
--header 'Authorization: key=API_ACCESS_KEY' \ | |
--header 'Content-Type: application/json' \ | |
--data-raw '{ | |
"to": "CLIENT_PUSH_TOKEN", | |
"notification": { | |
"body": "Push text message", | |
"title": "Push title" | |
}, | |
"data": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"to": "CLIENT_PUSH_TOKEN", | |
"notification": { | |
"body": "Push text message", | |
"title": "Push title" | |
}, | |
"data": { | |
"some_important_id": "1234" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public suspend fun send(element: E) | |
public fun offer(element: E): Boolean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public fun close(cause: Throwable? = null): Boolean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (item in channel) { | |
// do something with item | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public suspend fun receive(): E | |
public fun poll(): E? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public fun cancel(cause: CancellationException? = null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.channels.produce | |
val receiveChannel = produce(context = Dispatchers.Default) { | |
for (i in 0..10) { | |
send(i) | |
} | |
} |
NewerOlder