Package org.fishwife.jrugged.interval

Examples of org.fishwife.jrugged.interval.DiscreteInterval


    }
   
    @Test
    public void canSleepUntilClockElapses() {
        expect(mockClock.getGranularity()).andReturn(1L).anyTimes();
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(4L,5L));
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(504L,505L));
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(704L,705L));
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(1005L,1006L));
        replay(mockClock);
        impl.set(1000L,100L);
        impl.start();
        impl.waitUntilElapsed();
        verify(mockClock);
View Full Code Here


    public void normalizesToPositiveReadings() {
        expect(mockEnv.nanoTime()).andReturn(-100L);
        expect(mockEnv.nanoTime()).andReturn(-90L).anyTimes();
        expect(mockEnv.currentTimeMillis()).andReturn(0L).anyTimes();
        replay(mockEnv);
        DiscreteInterval out = impl.getNanoTime();
        verify(mockEnv);
        assertTrue(out.getMin() >= 0);
        assertTrue(out.getMax() >= 0);
    }
View Full Code Here

    public DiscreteInterval getNanoTime() {
        long granularity = getGranularity();
        long err = granularity / 2;
        if (granularity % 2 == 1) err += 1;
        long now = env.nanoTime() + getOffset();
        return new DiscreteInterval(now - err, now + err);
    }
View Full Code Here

TOP

Related Classes of org.fishwife.jrugged.interval.DiscreteInterval

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.