HashedWheelTimer not executing scheduled tasks
esnjonas
jonas.tarnstrom at esn.me
Thu Jul 7 03:52:33 EDT 2011
Hi,
First of all, big thanks to Trustin Lee and the rest of the Netty
communnity.
And now to the problem :)
We're using Netty 3.2.4-Final and we are experiencing problems with the
HashedWheelTimer.
It simply skips executing a scheduled task if the task is scheduled again
from within the run-method of the TimerTask.
I've identified the the time spent inside the run method affects this
scenario. This simple test below fails on both Linux and Windows.
import org.jboss.netty.util.HashedWheelTimer;
import org.jboss.netty.util.Timeout;
import org.jboss.netty.util.TimerTask;
import org.junit.Test;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.Assert.assertTrue;
public class HashedWheelTimerTest
{
private static class TestTimeout implements TimerTask
{
protected final AtomicInteger execCount = new AtomicInteger(0);
public void run(Timeout timeout) throws Exception
{
Thread.sleep(1000);
execCount.incrementAndGet();
timeout.getTimer().newTimeout(this, 100, TimeUnit.MILLISECONDS);
}
}
@Test
public void testExpire() throws InterruptedException
{
HashedWheelTimer wheelTimer = new HashedWheelTimer(100,
TimeUnit.MILLISECONDS);
wheelTimer.start();
TestTimeout tt = new TestTimeout();
wheelTimer.newTimeout(tt, 100, TimeUnit.MILLISECONDS);
Thread.sleep(5000);
wheelTimer.stop();
assertTrue(tt.execCount.get() > 1);
}
}
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/HashedWheelTimer-not-executing-scheduled-tasks-tp6557454p6557454.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list