title: SIGALRM Timeout -- How does it affect existing operations?
body: <p>I am currently using <code>select()</code> to act as a timer. I have network receive operations which occur within a loop, and every few seconds a processing operation needs to occur.</p>
  
  <p>As a result, the select() statement's timeout constantly changes -- decreasing to zero over time and then restarting at 3.</p>
  
  <p><code>rv = select(selectmonitor+1, &amp;readnet, NULL, NULL, &amp;helper.timeout());</code></p>
  
  <p>As things come in on the network, the statement is repeated and the value passed to it by helper.timeout() decreases. Eventually, the value will either be equal to zero or the system will timeout, which will result in the processing function executing. However, I've noticed that this is quite resource intensive -- the value for helper.timeout() must be constantly calculated. When I am trying to receive a few thousand packets a second, the time it takes for this operation to be done results in packet loss.</p>
  
  <p>My new idea is using <code>SIGALRM</code> to resolve this. This would allow me to set a timer once and then react when it is set off. However, I'm confused as to how it will affect my program. When SIGALRM 'goes off', it will run a function which I specify. However, how will it interrupt my existing code? And once the function is done, how will my existing code (within the <code>while</code> statement) resume?</p>
  
  <p>Also, it would appear its impossible to set the SIGALRM signal to call a function within a class? Is this correct? I imagine I can call a function, which can in turn call a function within a class..</p>
  
  <p>Thanks for any assistance ahead of time.</p>