Created
December 6, 2017 10:57
-
-
Save lenstr/1af5727cbe01ce0b5855b693f9871019 to your computer and use it in GitHub Desktop.
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
suspend fun uvClose(handle: CPointer<uv_handle_t>): Unit = suspendCoroutine { cont -> | |
handle.pointed.data = StableRef.create(cont).asCPointer() | |
uv_close(handle, staticCFunction { handle: CPointer<uv_handle_t>? -> | |
handle ?: return@staticCFunction | |
val data = handle.pointed.data ?: return@staticCFunction | |
val contRef = data.asStableRef<Continuation<Unit>>() | |
contRef.get().resume(Unit) | |
contRef.dispose() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment