On 6/29/20 5:14 AM, ichneumwn wrote:
Dear all,
Is there some facility in D for a single statement/function call that
will wait on both file descriptors, like Socket.select(), and will also
wake up when there is something to be receive()'d?
Not in the standard library. Such things require an event framework,
because there is no OS-agnostic provided mechanism to sleep on all these
things at once.
I recommend looking through code.dlang.org. I found these:
https://code.dlang.org/packages/libasync
https://code.dlang.org/packages/eventcore
https://code.dlang.org/packages/mecca (this seems very underdocumented,
but I know it provides such a system)
One solution would be to have my main thread use receive() and a helper
thread that does the select() call and sends a message to the main
thread. That seems a bit of overkill however.
I don't know the correct way to solve this, I've done it in the past by
creating a file descriptor that can be waited on to wake up the target
along with any other file descriptors being waited on.
-Steve