title: Lua microseconds sleep
body: <p>Ok, I need to wait (for instance) for 10 us in my lua script. Is there any way to do it?</p>
  
  <p>For now I use this simple (non busy-waiting) function using <code>socket</code>:</p>
  
  <pre><code>function my_utils.sleep(sec)
      socket.select(nil, nil, sec)
  end
  </code></pre>
  
  <p>but it seems its "sleep minimum" is milliseconds.</p>
  
  <p>Example 1:</p>
  
  <pre><code>for x=0,2*math.pi,0.008 do
      misc.printus()
      misc.sleep(0.001)
  end
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>0.022654
  0.023654
  0.024654
  0.025654
  0.026654
  0.027654
  0.028654
  0.029654
  0.030654
  0.031654
  0.032654
  ...
  </code></pre>
  
  <p>Not bad!</p>
  
  <p>Example 2:</p>
  
  <pre><code>for x=0,2*math.pi,0.008 do
      misc.printus()
      misc.sleep(0.0001)
  end
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>0.537089
  0.537089
  0.537089
  0.537089
  ... --(lots of)
  38089
  0.538089
  0.538089
  0.538089
  0.538089
  0.538089
  0.538089
  ... --(lots of)
  0.538089
  0.577091 -- (jumps over 0.04 second!)
  0.577091
  0.577091
  0.577091
  0.577091
  ... --(and so on)
  </code></pre>
  
  <p>Could someone give me some explanations (and about 0.04 second jump)?</p>