Search in sources :

Example 1 with ReadyRunnable

use of org.opennms.netmgt.scheduler.ReadyRunnable in project opennms by OpenNMS.

the class MockScheduler method next.

public long next() {
    if (m_scheduleEntries.isEmpty()) {
        throw new IllegalStateException("Nothing scheduled");
    }
    Long nextTime = m_scheduleEntries.firstKey();
    List<ReadyRunnable> entries = m_scheduleEntries.get(nextTime);
    Runnable runnable = entries.get(0);
    m_timer.setCurrentTime(nextTime.longValue());
    entries.remove(0);
    if (entries.isEmpty()) {
        m_scheduleEntries.remove(nextTime);
    }
    runnable.run();
    m_numTasksExecuted++;
    return getCurrentTime();
}
Also used : ReadyRunnable(org.opennms.netmgt.scheduler.ReadyRunnable) ReadyRunnable(org.opennms.netmgt.scheduler.ReadyRunnable)

Aggregations

ReadyRunnable (org.opennms.netmgt.scheduler.ReadyRunnable)1