Re: Waiting on file descriptor/socket *AND* thread messages

2020-06-29 Thread ichneumwn via Digitalmars-d-learn
On Monday, 29 June 2020 at 12:25:16 UTC, Steven Schveighoffer 
wrote:

On 6/29/20 5:14 AM, ichneumwn wrote:

[...]


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)



[...]


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


Thanks for the pointers Steve!


Re: Waiting on file descriptor/socket *AND* thread messages

2020-06-29 Thread Steven Schveighoffer via Digitalmars-d-learn

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


Waiting on file descriptor/socket *AND* thread messages

2020-06-29 Thread ichneumwn via Digitalmars-d-learn

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?


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.


Apologies if this has been asked before, but my google search and 
search in this thread were fruitless (could be my searching 
skills)


Cheers