Boost logo

Boost Users :

Subject: Re: [Boost-users] Asynchronous signals library
From: Anthony Foiani (tkil_at_[hidden])
Date: 2012-05-26 01:54:51


Edward Diener <eldiener_at_[hidden]> writes:

> Is there any Boost library, based on the function prototyping
> methods of signals(2), in which the signals are handled
> asynchronously ?

Within Boost, I see Thread and ASIO as the primary methods of working
asynchronously. (There's also Coroutine, maybe a few more; I haven't
kept up with the latest additions.)

As for hooking up to Unix-level signals, some platforms provide
methods for mapping signals onto file descriptors. On Linux, see
'signalfd(2)'.

If you don't have that, a back up method is to start a thread that
does nothing but wait for signals; when a signal is caught by that
thread, it sends some sort of notification through a file descriptor
(e.g., using 'pipe(2)' before creating the thread). The other end of
that pipe is now a file descriptor that generates read events when a
signal is caught.

Once you have that file descriptor, you can use it with ASIO or with
raw system calls. (Or in threads, if you have one thread that does a
select/poll loop then dispatches to worker threads.)

Does that answer your question, or did I totally misunderstand it? :)

Happy hacking,
t.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net