Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Jan Hudec's answer is correct, although I wouldn't recommend using signals for a few reasons:</p> <ul> <li>Older versions of glibc emulated <code>pselect</code> and <code>ppoll</code> in a non-atomic fashion, making them basically worthless. Even when you used the mask correctly, signals could get "lost" between the <code>pthread_sigprocmask</code> and <code>select</code> calls, meaning they don't cause <code>EINTR</code>.</li> <li>I'm not sure <code>signalfd</code> is any more efficient than the pipe. (Haven't tested it, but I don't have any particular reason to believe it is.)</li> <li>signals are generally a pain to get right. I've spent a lot of effort on them (see <a href="http://www.slamb.org/projects/sigsafe/" rel="nofollow">my sigsafe library</a>) and I'd recommend avoiding them if you can.</li> </ul> <p>Since you're trying to have asynchronous handling portable to several systems, I'd recommend looking at libevent. It will abstract <code>epoll</code> or <code>kqueue</code> for you, and it will even wake up workers on your behalf when you add a new event. See <a href="http://levent.git.sourceforge.net/git/gitweb.cgi?p=levent/libevent;a=blob;f=event.c;h=66fbfd588c62cf6a03932de776331379af42dc31;hb=HEAD" rel="nofollow">event.c</a></p> <pre><code>2058 static inline int 2059 event_add_internal(struct event *ev, const struct timeval *tv, 2060 int tv_is_absolute) 2061 { ... 2189 /* if we are not in the right thread, we need to wake up the loop */ 2190 if (res != -1 &amp;&amp; notify &amp;&amp; EVBASE_NEED_NOTIFY(base)) 2191 evthread_notify_base(base); ... 2196 } </code></pre> <p>Also,</p> <blockquote> <p>The worker thread deals with both socket I/O and asynchronous disk I/O, which means that it is optimally always waiting for the event queuing mechanism (epoll/kqueue).</p> </blockquote> <p>You're likely to be disappointed here. These event queueing mechanisms don't really support asynchronous disk I/O. See <a href="http://archives.seul.org/libevent/users/Sep-2011/msg00018.html" rel="nofollow">this recent thread</a> for more details.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload