Switch to System.nanoTime() to calculate block time of Selector.select(..)

This commit is contained in:
Norman Maurer 2012-08-26 18:48:50 +02:00
parent ff3f2b6361
commit 798390fc4d

View File

@ -253,10 +253,10 @@ abstract class AbstractNioWorker implements Worker {
} }
try { try {
long beforeSelect = System.currentTimeMillis(); long beforeSelect = System.nanoTime();
int selected = SelectorUtil.select(selector); int selected = SelectorUtil.select(selector);
if (selected == 0) { if (selected == 0) {
long timeBlocked = System.currentTimeMillis() - beforeSelect; long timeBlocked = System.nanoTime() - beforeSelect;
if (timeBlocked < SelectorUtil.SELECT_WAIT_TIME) { if (timeBlocked < SelectorUtil.SELECT_WAIT_TIME) {
// returned before the SELECT_WAIT_TIME elapsed with nothing select. // returned before the SELECT_WAIT_TIME elapsed with nothing select.
// this may be the cause of the jdk epoll(..) bug, so increment the counter // this may be the cause of the jdk epoll(..) bug, so increment the counter