Created
December 6, 2017 10:56
-
-
Save lenstr/04d884fe648fc5827921f8c104a22046 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