title: Is it efficient to use epoll with devices (/dev/event/...)?
body: <p>I am working on a <em>monothreaded</em> process applet which creates a proxy virtual device (more precisely a virtual <em>Xbox 360</em> pad); I do manage to create it with the <a href="http://thiemonge.org/getting-started-with-uinput">uinput</a> interface, I set it up properly and it works just fine.</p>
  
  <p>In order to feed commands to this <em>virtual device</em>, I read events from another <em>real</em> interface (in this case a <em>PS3</em> pad), and I open the <em>real device</em> file with these flags:</p>
  
  <pre><code>fd = open("/dev/input/event22", O_RDONLY); // open the PS3 pad
  </code></pre>
  
  <p>The main loop is something like (minus error checking):</p>
  
  <pre><code>while(run) {
      input_event ev = {0};
      read(fd, &amp;ev, sizeof(struct input_event));
      // convert from PS3 --&gt; Xbox 360
      convert(ev);
      // write to the new virtual pad
      write(fd_virtual, &amp;ev, sizeof(struct input_event));
  }
  </code></pre>
  
  <p>As you can imagine the <code>read(fd, &amp;ev, sizeof(struct input_event));</code> is a blocking call and I would like to have a sort of timeout to cycle through the loop and check for other events/execute other code.</p>
  
  <p>For these reasons I am thinking of encapsulating that <code>read(fd...</code> call inside an <a href="https://linux.die.net/man/7/epoll">epoll</a> loop, so I can also have a timeout.</p>
  
  <p>Question is, would it be efficient to have it done this way?
  By virtue of using <a href="https://linux.die.net/man/2/epoll_wait">epoll_wait</a>, am I introducing additional delays to the current loop, thus delays in responsiveness of the <em>virtual pad</em>?</p>