Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Commit

Permalink
Sync from next
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz committed Mar 4, 2021
1 parent dce48e7 commit 8b3f6d6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ coroutinesVersion=1.4.2

# korlibs
klockVersion=2.0.6
kdsVersion=2.0.7
kmemVersion=2.0.7
kdsVersion=2.0.8
kmemVersion=2.0.8
kryptoVersion=2.0.6
kloggerVersion=2.0.7

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ abstract class BaseSignal<T, THandler>(val onRegister: () -> Unit = {}) {
}
protected var iterating: Int = 0
protected inline fun iterateCallbacks(callback: (THandler) -> Unit) {
if (handlers.isEmpty()) return
try {
iterating++
handlers.fastIterateRemove { node ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.soywiz.korio.async

import com.soywiz.korio.lang.*
import kotlinx.coroutines.*
import kotlin.jvm.*

suspend fun <T> waitSubscriber(block: ((T) -> Unit) -> Cancellable): T {
val deferred = CompletableDeferred<T>()
@Suppress("JoinDeclarationAndAssignment")
lateinit var cancellable: Cancellable
cancellable = block {
cancellable.cancel()
deferred.complete(it)
}
try {
return deferred.await()
} catch (e: CancellationException) {
cancellable.cancel()
throw e
}
}

suspend fun <T> waitSubscriberCloseable(block: ((T) -> Unit) -> Closeable): T =
waitSubscriber { block(it).cancellable() }
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class RedirectMutableField<V>(val redirect: KMutableProperty0<V>) {
}

// @TODO: Shouldn't be required anymore
@Deprecated("Shouldn't be required anymore")
fun <V> redirect(prop: KMutableProperty0<V>) = RedirectMutableField(prop)
@Deprecated("Shouldn't be required anymore")
fun <V> redirect(prop: KProperty0<V>) = RedirectField(prop)

class RedirectMutableFieldGen<V>(val redirect: () -> KMutableProperty0<V>) {
Expand All @@ -26,7 +28,9 @@ class RedirectFieldGen<V>(val redirect: () -> KProperty0<V>) {

inline fun <V> (() -> KProperty0<V>).redirected() = RedirectFieldGen(this)
inline fun <V> (() -> KMutableProperty0<V>).redirected() = RedirectMutableFieldGen(this)
@Deprecated("Shouldn't be required anymore")
inline fun <V> KMutableProperty0<V>.redirected() = RedirectMutableField(this)
@Deprecated("Shouldn't be required anymore")
inline fun <V> KProperty0<V>.redirected() = RedirectField(this)

class TransformedField<V, R>(val prop: KProperty0<V>, val transform: (V) -> R) {
Expand Down

0 comments on commit 8b3f6d6

Please sign in to comment.