Use our native (select()-based) sleep() on Linux to achieve 10ms

granularity instead of 20ms which is what we get from Thread.sleep() which
probably uses the less than aptly named nanosleep() which seems to give
about that granularity.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2557 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2003-05-08 21:26:27 +00:00
parent ff691ca88c
commit fa5c8cc6a3
@@ -1,5 +1,5 @@
//
// $Id: FrameManager.java,v 1.41 2003/05/02 23:53:55 mdb Exp $
// $Id: FrameManager.java,v 1.42 2003/05/08 21:26:27 mdb Exp $
package com.threerings.media;
@@ -42,6 +42,7 @@ import com.samskivert.util.StringUtil;
import com.threerings.media.timer.MediaTimer;
import com.threerings.media.timer.SystemMediaTimer;
import com.threerings.media.util.TrailingAverage;
import com.threerings.util.unsafe.Unsafe;
/**
* Provides a central point from which the computation for each "frame" or
@@ -681,16 +682,7 @@ public abstract class FrameManager
if (MediaPanel._perfDebug.getValue()) {
start = _timer.getElapsedMillis();
}
try {
int sleepGran = _sleepGranularity.getValue();
if (sleepGran > 0) {
Thread.sleep(sleepGran);
} else {
Thread.yield();
}
} catch (InterruptedException ie) {
Log.warning("Ticker thread interrupted.");
}
Unsafe.sleep(_sleepGranularity.getValue());
long woke = _timer.getElapsedMillis();
if (start > 0L) {