I have an event loop with its own dedicated thread...
# coroutines
I have an event loop with its own dedicated thread, which has a suspending method for submitting events (suspends until the event is done dispatching). Let's say I'm hooking a pre-existing event loop into it, like a slack bot library. What should I consider when deciding which thread to submit events from (and therefore suspend)? Or should I submit events blocking from the main thread to keep everything in step with the event loop?
Why are you suspending?
@Dico listeners on the event loop can perform suspending operations, so the submission suspends as well to let all listeners complete their work
Ok, dispatching in that sense
So with coroutines you have the ability to suspend a coroutine, which does not block a thread
Your event loop can have a single coroutine to guarantee a deterministic order of execution
But this constraint likely isn't necessary for communication with your app
So you should seek to launch a new coroutine to call your suspending dispatch function, whose implementation then posts the task and awaits listener completion
­čĹŹ­čĆ╗ 1
That way you dont block any activity
Yeah, the event loop has a single coroutine that it runs. I guess, fundamentally, the question is: do I need my application to be in step with the event loop? Should I be suspending all other functionality while events are happening? To which the answers seems to be no
This is my advice based on limited context at least