public void addTimer(long timeout, IPollEvents sink, int id)
    {
        assert (Thread.currentThread() == worker);

        final long expiration = clock() + timeout;
        TimerInfo info = new TimerInfo(sink, id);
        timers.insert(expiration, info);

        changed = true;
    }
@Test
    public void testAddTimer()
    {
        final PollerBaseTested poller = new PollerBaseTested();

        poller.addTimer(1000, new PollEvents()
        {
            private boolean first = true;

            @Override
            public void timerEvent(int id)
            {
                if (first) {
                    // expires at 2000 + 1000
                    poller.addTimer(2000, this, id);
                }
                first = false;
            }
        }, 1);
        poller.clock(1000);
        long timeout = poller.executeTimers();

        assertThat(poller.isEmpty(), is(false));
        assertThat(timeout, is(2000L));

        poller.clock(3000);
        timeout = poller.executeTimers();

        assertThat(timeout, is(0L));
        assertThat(poller.isEmpty(), is(true));
    }