Bruno Haible <br...@clisp.org> wrote:
> Hi Eric,
> 
> Eric Wong wrote:
> > I would've recommended just using a pipe, socket or eventfd;
> 
> How would setting up a pipe or eventfd help with a communication
> problem between threads in the same process? I thought these were
> for communication between processes.

The "self-pipe trick" is a common idiom in Unix for signal
handling; especially when pselect/ppoll aren't available.
I seem to recall learning of it reading something by djb.

It's perfectly valid to use pipes in single-threaded or
multi-threaded, or multi-process situations.  POSIX gives
well-defined semantics w.r.t. atomicity.

I know the (C)Ruby VM uses it internally (or eventfd on Linux);
I think CPython's GVL does, too.

My gnulib-using cmogstored uses a self-pipe when epoll_pwait
isn't available (Though it could probably use EVFILT_SIGNAL on
*BSD).

Reply via email to