title: Linux, C++, Waiting for an event using poll/select ( w/o blocking the executing thread )
body: <h2>Use-case</h2>
  
  <ul>
  <li>Single threaded Application</li>
  <li>Non-blocking Async-IO using <strong><a href="http://linux.die.net/man/2/poll" rel="nofollow">poll</a></strong></li>
  <li>A waitable object ( eg. a mutex ) with a timeout period</li>
  </ul>
  
  <h2>Problem at hand</h2>
  
  <p>I don;t want to create a specialized thread to wait for a timeout, and thus, I want to use <strong><a href="http://linux.die.net/man/2/poll" rel="nofollow">poll</a></strong> to wait for a timeout on the waitable object in an ~Async~ fashion.</p>
  
  <p>Is it possible to get notified for a mutex wait timeout using <strong><a href="http://linux.die.net/man/2/poll" rel="nofollow">poll</a></strong>?</p>
  
  <h2>Main thread Pseudo code</h2>
  
  <ul>
  <li>Existing logic
  <ol>
  <li>wait for multiple FDs using <strong><a href="http://linux.die.net/man/2/poll" rel="nofollow">poll</a></strong></li>
  <li>for each ~ready~ FD, process the IO</li>
  <li>goto #1</li>
  </ol></li>
  <li><em>Desired</em> Logic
  <ol>
  <li>wait for multiple FDs <strong>and Mutexes</strong> using <strong><a href="http://linux.die.net/man/2/poll" rel="nofollow">poll</a></strong></li>
  <li>for each ~ready~ FD, process the IO</li>
  <li>For each timedout mutex process timeout ( eg. execute a registered callback )</li>
  <li>For each signaled mutex process wait completion</li>
  <li>goto #1</li>
  </ol></li>
  </ul>