Closed Spliterash closed 1 year ago
That's true and that's a limitation I have accepted when writing MCCoroutine. I am not sure how to reliably detect if the current thread is one of the threads of the Bukkit async thread pool.
Solution is quite simple: Use Dispatchers.IO
from Kotlin Coroutines. The asyncDispatcher can be seen more like convenient feaure. I also recommend to use Dispatchers.IO
in the wiki.
Then please note it somehow in the documentation, because I didn't know about this limitation and I mistakenly dispatched my tasks to lettuce and mognoreactive
I'll leave this issue open to let myself know to improve the wiki regarding that.
When I use asycnDispatcher it behaves like
Dispatchers.Unconfined
in every way, unless it is the main thread. Because of this, I caught a lot of errors, because I thought that he would always switch thread to the asynchronous bukkit, but it continued to execute in the lettuce thread, for exampleDispatch method from
com.github.shynixn.mccoroutine.bukkit.dispatcher.AsyncCoroutineDispatcher