https://kotlinlang.org logo
Title
a

Andrew Gazelka

05/01/2019, 10:52 PM
how do you suggest me making a custom IO dispatcher? (there will be a loop on the main thread which updates coroutines every 20 ms)
my wrong approach was to have
object MyDispatcher : CoroutineDispatcher() {

        val toRun = LinkedList<Runnable>()

        override fun dispatch(context: CoroutineContext, block: Runnable) {
            toRun.add(block)
        }

        fun runAll() {
            toRun.forEach { it.run() }
        }

    }
and just run
MyDispatcher.runAll()
g

gildor

05/02/2019, 1:50 AM
What is your use case for this?
a

Andrew Gazelka

05/02/2019, 2:06 AM
@gildor there is something which is similar to a UI thread (for Minecraft) where I need to run certain things on the main thread
Which is run every 50 ms
nvm already implemented https://github.com/okkero/Skedule