forked from I2P_Developers/i2p.i2p
* Streaming: Scheduler cleanup
This commit is contained in:
@@ -11,11 +11,11 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SchedulerChooser {
|
class SchedulerChooser {
|
||||||
private I2PAppContext _context;
|
private final I2PAppContext _context;
|
||||||
private Log _log;
|
private final Log _log;
|
||||||
private TaskScheduler _nullScheduler;
|
private final TaskScheduler _nullScheduler;
|
||||||
/** list of TaskScheduler objects */
|
/** list of TaskScheduler objects */
|
||||||
private List _schedulers;
|
private final List _schedulers;
|
||||||
|
|
||||||
public SchedulerChooser(I2PAppContext context) {
|
public SchedulerChooser(I2PAppContext context) {
|
||||||
_context = context;
|
_context = context;
|
||||||
@@ -48,8 +48,9 @@ class SchedulerChooser {
|
|||||||
rv.add(new SchedulerDead(_context));
|
rv.add(new SchedulerDead(_context));
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NullScheduler implements TaskScheduler {
|
private class NullScheduler implements TaskScheduler {
|
||||||
private Log _log;
|
private final Log _log;
|
||||||
public NullScheduler() {
|
public NullScheduler() {
|
||||||
_log = _context.logManager().getLog(NullScheduler.class);
|
_log = _context.logManager().getLog(NullScheduler.class);
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package net.i2p.client.streaming;
|
package net.i2p.client.streaming;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.util.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Scheduler used for after both sides have had their close packets
|
* <p>Scheduler used for after both sides have had their close packets
|
||||||
@@ -25,10 +24,8 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SchedulerClosed extends SchedulerImpl {
|
class SchedulerClosed extends SchedulerImpl {
|
||||||
private Log _log;
|
|
||||||
public SchedulerClosed(I2PAppContext ctx) {
|
public SchedulerClosed(I2PAppContext ctx) {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
_log = ctx.logManager().getLog(SchedulerClosed.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean accept(Connection con) {
|
public boolean accept(Connection con) {
|
||||||
|
@@ -27,10 +27,9 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SchedulerClosing extends SchedulerImpl {
|
class SchedulerClosing extends SchedulerImpl {
|
||||||
private Log _log;
|
|
||||||
public SchedulerClosing(I2PAppContext ctx) {
|
public SchedulerClosing(I2PAppContext ctx) {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
_log = ctx.logManager().getLog(SchedulerClosing.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean accept(Connection con) {
|
public boolean accept(Connection con) {
|
||||||
|
@@ -30,10 +30,9 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SchedulerConnectedBulk extends SchedulerImpl {
|
class SchedulerConnectedBulk extends SchedulerImpl {
|
||||||
private Log _log;
|
|
||||||
public SchedulerConnectedBulk(I2PAppContext ctx) {
|
public SchedulerConnectedBulk(I2PAppContext ctx) {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
_log = ctx.logManager().getLog(SchedulerConnectedBulk.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean accept(Connection con) {
|
public boolean accept(Connection con) {
|
||||||
|
@@ -27,11 +27,9 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SchedulerConnecting extends SchedulerImpl {
|
class SchedulerConnecting extends SchedulerImpl {
|
||||||
private Log _log;
|
|
||||||
|
|
||||||
public SchedulerConnecting(I2PAppContext ctx) {
|
public SchedulerConnecting(I2PAppContext ctx) {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
_log = ctx.logManager().getLog(SchedulerConnecting.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean accept(Connection con) {
|
public boolean accept(Connection con) {
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package net.i2p.client.streaming;
|
package net.i2p.client.streaming;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.util.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Scheduler used for after the final timeout has passed or the
|
* <p>Scheduler used for after the final timeout has passed or the
|
||||||
@@ -24,10 +23,9 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SchedulerDead extends SchedulerImpl {
|
class SchedulerDead extends SchedulerImpl {
|
||||||
private Log _log;
|
|
||||||
public SchedulerDead(I2PAppContext ctx) {
|
public SchedulerDead(I2PAppContext ctx) {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
_log = ctx.logManager().getLog(SchedulerDead.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean accept(Connection con) {
|
public boolean accept(Connection con) {
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package net.i2p.client.streaming;
|
package net.i2p.client.streaming;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.util.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Scheduler used after we've locally done a hard disconnect,
|
* <p>Scheduler used after we've locally done a hard disconnect,
|
||||||
@@ -25,10 +24,9 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SchedulerHardDisconnected extends SchedulerImpl {
|
class SchedulerHardDisconnected extends SchedulerImpl {
|
||||||
private Log _log;
|
|
||||||
public SchedulerHardDisconnected(I2PAppContext ctx) {
|
public SchedulerHardDisconnected(I2PAppContext ctx) {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
_log = ctx.logManager().getLog(SchedulerHardDisconnected.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean accept(Connection con) {
|
public boolean accept(Connection con) {
|
||||||
|
@@ -8,8 +8,8 @@ import net.i2p.util.SimpleScheduler;
|
|||||||
* Base scheduler
|
* Base scheduler
|
||||||
*/
|
*/
|
||||||
abstract class SchedulerImpl implements TaskScheduler {
|
abstract class SchedulerImpl implements TaskScheduler {
|
||||||
protected I2PAppContext _context;
|
protected final I2PAppContext _context;
|
||||||
private Log _log;
|
protected final Log _log;
|
||||||
|
|
||||||
public SchedulerImpl(I2PAppContext ctx) {
|
public SchedulerImpl(I2PAppContext ctx) {
|
||||||
_context = ctx;
|
_context = ctx;
|
||||||
@@ -17,6 +17,6 @@ abstract class SchedulerImpl implements TaskScheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void reschedule(long msToWait, Connection con) {
|
protected void reschedule(long msToWait, Connection con) {
|
||||||
SimpleScheduler.getInstance().addEvent(con.getConnectionEvent(), msToWait);
|
_context.simpleScheduler().addEvent(con.getConnectionEvent(), msToWait);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,11 +22,9 @@ import net.i2p.util.Log;
|
|||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
class SchedulerPreconnect extends SchedulerImpl {
|
class SchedulerPreconnect extends SchedulerImpl {
|
||||||
private Log _log;
|
|
||||||
|
|
||||||
public SchedulerPreconnect(I2PAppContext ctx) {
|
public SchedulerPreconnect(I2PAppContext ctx) {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
_log = ctx.logManager().getLog(SchedulerPreconnect.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean accept(Connection con) {
|
public boolean accept(Connection con) {
|
||||||
|
@@ -9,11 +9,9 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SchedulerReceived extends SchedulerImpl {
|
class SchedulerReceived extends SchedulerImpl {
|
||||||
private Log _log;
|
|
||||||
|
|
||||||
public SchedulerReceived(I2PAppContext ctx) {
|
public SchedulerReceived(I2PAppContext ctx) {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
_log = ctx.logManager().getLog(SchedulerReceived.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean accept(Connection con) {
|
public boolean accept(Connection con) {
|
||||||
@@ -46,4 +44,4 @@ class SchedulerReceived extends SchedulerImpl {
|
|||||||
reschedule(timeTillSend, con);
|
reschedule(timeTillSend, con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user