F0X
12/27/2020, 12:26 PMMainCoroutineDispatcher
that simply runs the coroutines on an existing main thread?Main
dispatcher to use one existing, plain java thread. I am not working in an environment where this already exists, like Android, Swing or JavaFXDispatchers.Main
does not exist without someone registering the appropriate service, which is what I want to do.
Because I am integrating this code into an existing Program as a kind of "Plugin" I want to create a simple Dispatcher that runs all coroutines on this single existing thread.Chrimaeon
12/27/2020, 1:31 PMDominaezzz
12/27/2020, 1:44 PMrunBlocking
which creates a dispatcher on the calling thread for the coroutines to run.
If you're looking to create a dispatcher object, I think that can be done in a useful way since the dispatcher has to take control of the thread by blocking it.F0X
12/27/2020, 3:06 PMExecutor
for running things on the main thread, so I could just do as @Chrimaeon suggested and delegate to this.
Even though it seems a bit hacky using this "InternalCoroutinesApi" to set Dispatchers.Main
myself everything is working fine so far.
Thank you all for helping out!