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