Skip to content

Instantly share code, notes, and snippets.

@mehdok
Created December 8, 2018 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehdok/fe98a99f49501afb39e35773cc977219 to your computer and use it in GitHub Desktop.
Save mehdok/fe98a99f49501afb39e35773cc977219 to your computer and use it in GitHub Desktop.
import kotlin.coroutines.*
import kotlinx.coroutines.*
import platform.darwin.*
internal actual val dispatcher: CoroutineDispatcher = NsQueueDispatcher(dispatch_get_main_queue())
internal class NsQueueDispatcher(private val dispatchQueue: dispatch_queue_t) : CoroutineDispatcher() {
override fun dispatch(context: CoroutineContext, block: Runnable) {
dispatch_async(dispatchQueue) {
block.run()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment