https://kotlinlang.org logo
#coroutines
Title
# coroutines
d

Daniel Pitts

12/12/2023, 5:15 PM
If I wanted to create my own MainCoroutineDispatcher(), what's the fastest way to do so?
z

Zach Klippenstein (he/him) [MOD]

12/12/2023, 5:46 PM
Why?
d

Daniel Pitts

12/12/2023, 5:46 PM
I’m playing around with lwjgl and it has a lot of methods that need to run from the main thread on OSX.
Seems like it would be the right bridge for coroutines and LWJGL
k

kevin.cianfarini

12/12/2023, 5:51 PM
I don't know what lwjgl is, but have you considered looking at other implementations of main dispatchers? It will require hooking dispatch calls up to whatever the platforms equivalent would be. Eg. Post on Android loopers
d

Daniel Pitts

12/12/2023, 5:52 PM
I looked at the Swing implementation. It looks kind of simple. I’m just not sure how the loader finds the factory.
LWJGL is “Light Weight Java Gaming Library”. It’s a JVM interface into OpenGL/OpenCL/OpenAL.
👍 1
d

Dmitry Khalanskiy [JB]

12/13/2023, 9:37 AM
The fastest way would be to copy-paste code from something like https://github.com/Kotlin/kotlinx.coroutines/tree/master/ui/kotlinx-coroutines-swing, including the resource directory.
thank you color 1