forked from I2P_Developers/i2p.i2p
#1069: Deprecated SimpleScheduler and moved functionality into SimpleTimer2
This commit is contained in:
@@ -328,7 +328,7 @@ public class I2PSnarkUtil {
|
||||
return rv;
|
||||
} catch (I2PException ie) {
|
||||
_banlist.add(dest);
|
||||
_context.simpleScheduler().addEvent(new Unbanlist(dest), 10*60*1000);
|
||||
_context.simpleTimer2().addEvent(new Unbanlist(dest), 10*60*1000);
|
||||
IOException ioe = new IOException("Unable to reach the peer " + peer);
|
||||
ioe.initCause(ie);
|
||||
throw ioe;
|
||||
|
@@ -233,7 +233,7 @@ public class SnarkManager implements CompleteListener {
|
||||
// only if default instance
|
||||
if ("i2psnark".equals(_contextName))
|
||||
// delay until UpdateManager is there
|
||||
_context.simpleScheduler().addEvent(new Register(), 4*60*1000);
|
||||
_context.simpleTimer2().addEvent(new Register(), 4*60*1000);
|
||||
// Not required, Jetty has a shutdown hook
|
||||
//_context.addShutdownTask(new SnarkManagerShutdown());
|
||||
_idleChecker = new IdleChecker(this, _peerCoordinatorSet);
|
||||
@@ -2272,7 +2272,7 @@ public class SnarkManager implements CompleteListener {
|
||||
dht.stop();
|
||||
// Schedule this even for final shutdown, as there's a chance
|
||||
// that it's just this webapp that is stopping.
|
||||
_context.simpleScheduler().addEvent(new Disconnector(), 60*1000);
|
||||
_context.simpleTimer2().addEvent(new Disconnector(), 60*1000);
|
||||
addMessage(_("Closing I2P tunnel after notifying trackers."));
|
||||
if (finalShutdown) {
|
||||
try { Thread.sleep(5*1000); } catch (InterruptedException ie) {}
|
||||
|
@@ -193,7 +193,7 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
|
||||
// handled inside P.U.H. for now
|
||||
//register((Updater)puh, PLUGIN, FILE, 0);
|
||||
new NewsTimerTask(_context, this);
|
||||
_context.simpleScheduler().addPeriodicEvent(new TaskCleaner(), TASK_CLEANER_TIME);
|
||||
_context.simpleTimer2().addPeriodicEvent(new TaskCleaner(), TASK_CLEANER_TIME);
|
||||
changeState(RUNNING);
|
||||
if (_cmgr != null)
|
||||
_cmgr.register(this);
|
||||
@@ -1397,7 +1397,7 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
|
||||
|
||||
private void finishStatus(String msg) {
|
||||
updateStatus(msg);
|
||||
_context.simpleScheduler().addEvent(new StatusCleaner(msg), STATUS_CLEAN_TIME);
|
||||
_context.simpleTimer2().addEvent(new StatusCleaner(msg), STATUS_CLEAN_TIME);
|
||||
}
|
||||
|
||||
private class StatusCleaner implements SimpleTimer.TimedEvent {
|
||||
|
@@ -38,7 +38,7 @@ class NewsTimerTask implements SimpleTimer.TimedEvent {
|
||||
delay += _context.random().nextLong(INITIAL_DELAY);
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Scheduling first news check in " + DataHelper.formatDuration(delay));
|
||||
ctx.simpleScheduler().addPeriodicEvent(this, delay, RUN_DELAY);
|
||||
ctx.simpleTimer2().addPeriodicEvent(this, delay, RUN_DELAY);
|
||||
// UpdateManager calls NewsFetcher to check the existing news at startup
|
||||
}
|
||||
|
||||
|
@@ -5,8 +5,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.util.ObjectCounter;
|
||||
import net.i2p.util.RandomSource;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
import net.i2p.util.SimpleTimer2;
|
||||
|
||||
/**
|
||||
* Count how often we have received an incoming connection
|
||||
@@ -33,7 +33,7 @@ class ConnThrottler {
|
||||
// shorten the initial period by a random amount
|
||||
// to prevent correlation across destinations
|
||||
// and identification of router startup time
|
||||
SimpleScheduler.getInstance().addPeriodicEvent(new Cleaner(),
|
||||
SimpleTimer2.getInstance().addPeriodicEvent(new Cleaner(),
|
||||
(period / 2) + RandomSource.getInstance().nextLong(period / 2),
|
||||
period);
|
||||
}
|
||||
|
@@ -781,7 +781,7 @@ class Connection {
|
||||
private boolean scheduleDisconnectEvent() {
|
||||
if (!_disconnectScheduledOn.compareAndSet(0, _context.clock().now()))
|
||||
return false;
|
||||
_context.simpleScheduler().addEvent(new DisconnectEvent(), DISCONNECT_TIMEOUT);
|
||||
_context.simpleTimer2().addEvent(new DisconnectEvent(), DISCONNECT_TIMEOUT);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -213,7 +213,7 @@ class ConnectionPacketHandler {
|
||||
final long delay = nextSendTime - now;
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("scheduling ack in "+delay);
|
||||
_context.simpleScheduler().addEvent(new AckDup(con), delay);
|
||||
_context.simpleTimer2().addEvent(new AckDup(con), delay);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@@ -16,7 +16,7 @@ abstract class SchedulerImpl implements TaskScheduler {
|
||||
}
|
||||
|
||||
protected void reschedule(long msToWait, Connection con) {
|
||||
_context.simpleScheduler().addEvent(con.getConnectionEvent(), msToWait);
|
||||
_context.simpleTimer2().addEvent(con.getConnectionEvent(), msToWait);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -13,10 +13,9 @@ import java.awt.Frame;
|
||||
import java.io.File;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
import net.i2p.util.SimpleTimer2;
|
||||
import net.i2p.util.SystemVersion;
|
||||
|
||||
import snoozesoft.systray4j.SysTrayMenu;
|
||||
import snoozesoft.systray4j.SysTrayMenuEvent;
|
||||
import snoozesoft.systray4j.SysTrayMenuIcon;
|
||||
@@ -66,7 +65,7 @@ public class SysTray implements SysTrayMenuListener {
|
||||
private SysTray() {
|
||||
_sysTrayMenuIcon.addSysTrayMenuListener(this);
|
||||
createSysTrayMenu();
|
||||
SimpleScheduler.getInstance().addPeriodicEvent(new RefreshDisplayEvent(), REFRESH_DISPLAY_FREQUENCY);
|
||||
SimpleTimer2.getInstance().addPeriodicEvent(new RefreshDisplayEvent(), REFRESH_DISPLAY_FREQUENCY);
|
||||
}
|
||||
|
||||
private static final long REFRESH_DISPLAY_FREQUENCY = 30*1000;
|
||||
|
Reference in New Issue
Block a user