Re: Linux signal handling - notifying a condition variable

2018-03-16 Thread James E. King III via Digitalmars-d
On Thursday, 15 March 2018 at 19:43:09 UTC, Patrick Schluter wrote: On Thursday, 15 March 2018 at 16:51:59 UTC, Jim King wrote: I am trying to add graceful shutdown support to a test harness. In the test harness, a server class consumes a thread to accept connections and service them. In

Re: Linux signal handling - notifying a condition variable

2018-03-15 Thread Patrick Schluter via Digitalmars-d
On Thursday, 15 March 2018 at 16:51:59 UTC, Jim King wrote: I am trying to add graceful shutdown support to a test harness. In the test harness, a server class consumes a thread to accept connections and service them. In order to stop the server, it has to be interrupted. This interruption

Re: Linux signal handling - notifying a condition variable

2018-03-15 Thread Dmitry Olshansky via Digitalmars-d
On Thursday, 15 March 2018 at 19:36:44 UTC, Patrick Schluter wrote: On Thursday, 15 March 2018 at 19:23:26 UTC, Dmitry Olshansky wrote: On Thursday, 15 March 2018 at 17:30:50 UTC, Jim King wrote: [...] Another option if you are on linux is to use eventfd. Then you can trigger it with simple

Re: Linux signal handling - notifying a condition variable

2018-03-15 Thread Patrick Schluter via Digitalmars-d
On Thursday, 15 March 2018 at 19:23:26 UTC, Dmitry Olshansky wrote: On Thursday, 15 March 2018 at 17:30:50 UTC, Jim King wrote: [...] Another option if you are on linux is to use eventfd. Then you can trigger it with simple write on eventfd descriptor. As far as waiting goes it’s either

Re: Linux signal handling - notifying a condition variable

2018-03-15 Thread Dmitry Olshansky via Digitalmars-d
On Thursday, 15 March 2018 at 17:30:50 UTC, Jim King wrote: On Thursday, 15 March 2018 at 17:12:24 UTC, Adam D. Ruppe wrote: On Thursday, 15 March 2018 at 16:51:59 UTC, Jim King wrote: In going through the signal documentation it looks like the signal handler must be a "nothrow @nogc" variety.

Re: Linux signal handling - notifying a condition variable

2018-03-15 Thread Adam D. Ruppe via Digitalmars-d
Alternatively btw you can use the pthreads C functions import core.sys.posix.pthread; which shuld also be nogc right now. The condition class wraps those on Linux fairly thinly; using the C functions should be little more trouble.

Re: Linux signal handling - notifying a condition variable

2018-03-15 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 15 March 2018 at 17:30:50 UTC, Jim King wrote: The problem with that is that it requires a busy loop to detect it. well, what's your thread doing? In the case I used this pattern, it was blocking on a call to select() anyway, so when it returned with EINTR, that was a good

Re: Linux signal handling - notifying a condition variable

2018-03-15 Thread Jim King via Digitalmars-d
On Thursday, 15 March 2018 at 17:12:24 UTC, Adam D. Ruppe wrote: On Thursday, 15 March 2018 at 16:51:59 UTC, Jim King wrote: In going through the signal documentation it looks like the signal handler must be a "nothrow @nogc" variety. Looks like notify actually can throw an exception... the

Re: Linux signal handling - notifying a condition variable

2018-03-15 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 15 March 2018 at 16:51:59 UTC, Jim King wrote: In going through the signal documentation it looks like the signal handler must be a "nothrow @nogc" variety. Looks like notify actually can throw an exception... the way I usually do signal handlers is just set a global variable:

Linux signal handling - notifying a condition variable

2018-03-15 Thread Jim King via Digitalmars-d
I am trying to add graceful shutdown support to a test harness. In the test harness, a server class consumes a thread to accept connections and service them. In order to stop the server, it has to be interrupted. This interruption mechanism is based on core.sync.condition. I want to add a