I think this might be leading me down a road that could actually work a lot 
better than what I currently have.

Say you have a threadServer (that is, a long-living thread that exists besides 
your main thread that you can send messages to and receive messages from).

You could also have a third thread, a "helper" thread, whose sole task it is to 
read messages from the channel for the threadServer blockingly and transform 
them into async work that it puts on the async-work-queue of the threadServer. 
That way, when no message is in the channel, the "helper" thread blocks on 
read, spinning it down to a more energy efficient state.

Meanwhile the "threadServer" itself only does one thing as well: Read from the 
async-work-queue and work through it. That way message processing happens and 
if that spawns more async events (because async-IO happens or sth) then that's 
not a problem since that thread **only** processes async-events.

Reply via email to