From 54dba980b42ef6cd9ba94d0886f244d902610ab4 Mon Sep 17 00:00:00 2001
From: dev <dev@robertfoss.se>
Date: Wed, 15 Apr 2015 15:32:40 +0000
Subject: [PATCH] #1069: Replaced SimpleScheduler with SimpleTimer2 in a few
 places

---
 apps/BOB/src/net/i2p/BOB/BOB.java                           | 3 ---
 apps/BOB/src/net/i2p/BOB/Main.java                          | 3 ---
 .../java/src/org/klomp/snark/PeerConnectionOut.java         | 2 --
 apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java    | 2 +-
 .../net/i2p/client/streaming/impl/ConnectionHandler.java    | 2 +-
 .../net/i2p/client/streaming/impl/MessageOutputStream.java  | 2 +-
 core/java/src/net/i2p/util/ByteCache.java                   | 2 +-
 core/java/src/net/i2p/util/SimpleTimer.java                 | 2 +-
 router/java/src/net/i2p/router/peermanager/PeerManager.java | 2 +-
 .../java/src/net/i2p/router/transport/udp/UDPReceiver.java  | 2 +-
 router/java/src/net/i2p/router/util/DecayingHashSet.java    | 6 +++---
 11 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/apps/BOB/src/net/i2p/BOB/BOB.java b/apps/BOB/src/net/i2p/BOB/BOB.java
index 6dbbe3712c..c4ef3b23a2 100644
--- a/apps/BOB/src/net/i2p/BOB/BOB.java
+++ b/apps/BOB/src/net/i2p/BOB/BOB.java
@@ -38,7 +38,6 @@ import net.i2p.I2PAppContext;
 import net.i2p.app.*;
 import net.i2p.client.I2PClient;
 import net.i2p.util.I2PAppThread;
-import net.i2p.util.SimpleScheduler;
 import net.i2p.util.SimpleTimer2;
 
 /**
@@ -214,9 +213,7 @@ public class BOB implements Runnable, ClientApp {
 		// Re-reading the config file in each thread is pretty damn stupid.
 		String configLocation = System.getProperty(PROP_CONFIG_LOCATION, "bob.config");
 		// This is here just to ensure there is no interference with our threadgroups.
-		SimpleScheduler Y1 = SimpleScheduler.getInstance();
 		SimpleTimer2 Y2 = SimpleTimer2.getInstance();
-		i = Y1.hashCode();
 		i = Y2.hashCode();
 		{
 			File cfg = new File(configLocation);
diff --git a/apps/BOB/src/net/i2p/BOB/Main.java b/apps/BOB/src/net/i2p/BOB/Main.java
index 89fd954893..9382cd44e8 100644
--- a/apps/BOB/src/net/i2p/BOB/Main.java
+++ b/apps/BOB/src/net/i2p/BOB/Main.java
@@ -15,7 +15,6 @@
  */
 package net.i2p.BOB;
 
-import net.i2p.util.SimpleScheduler;
 import net.i2p.util.SimpleTimer2;
 
 /**
@@ -31,12 +30,10 @@ public class Main {
 	 */
 	public static void main(String[] args) {
 		// THINK THINK THINK THINK THINK THINK
-		SimpleScheduler Y1 = SimpleScheduler.getInstance();
 		SimpleTimer2 Y2 = SimpleTimer2.getInstance();
 
 		BOB.main(args);
 
 		Y2.stop();
-		Y1.stop();
 	}
 }
diff --git a/apps/i2psnark/java/src/org/klomp/snark/PeerConnectionOut.java b/apps/i2psnark/java/src/org/klomp/snark/PeerConnectionOut.java
index c78ade3e86..b878c3b791 100644
--- a/apps/i2psnark/java/src/org/klomp/snark/PeerConnectionOut.java
+++ b/apps/i2psnark/java/src/org/klomp/snark/PeerConnectionOut.java
@@ -30,7 +30,6 @@ import java.util.concurrent.atomic.AtomicLong;
 import net.i2p.I2PAppContext;
 import net.i2p.util.I2PAppThread;
 import net.i2p.util.Log;
-//import net.i2p.util.SimpleScheduler;
 //import net.i2p.util.SimpleTimer;
 
 class PeerConnectionOut implements Runnable
@@ -480,7 +479,6 @@ class PeerConnectionOut implements Runnable
     m.len = length;
     // since we have the data already loaded, queue a timeout to remove it
     // no longer prefetched
-    //SimpleScheduler.getInstance().addEvent(new RemoveTooSlow(m), SEND_TIMEOUT);
     addMessage(m);
   }
 
diff --git a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
index e8931328c4..971a3c379f 100644
--- a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
+++ b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
@@ -2241,7 +2241,7 @@ public class SnarkManager implements CompleteListener {
      * Stop all running torrents, and close the tunnel after a delay
      * to allow for announces.
      * If called at router shutdown via Jetty shutdown hook -> webapp destroy() -> stop(),
-     * the tunnel won't actually be closed as the SimpleScheduler is already shutdown
+     * the tunnel won't actually be closed as the SimpleTimer2 is already shutdown
      * or will be soon, so we delay a few seconds inline.
      * @param finalShutdown if true, sleep at the end if any torrents were running
      * @since 0.9.1
diff --git a/apps/streaming/java/src/net/i2p/client/streaming/impl/ConnectionHandler.java b/apps/streaming/java/src/net/i2p/client/streaming/impl/ConnectionHandler.java
index 03486cc63c..2a41fe3ac8 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/impl/ConnectionHandler.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/impl/ConnectionHandler.java
@@ -96,7 +96,7 @@ class ConnectionHandler {
         // also check if expiration of the head is long past for overload detection with peek() ?
         boolean success = _synQueue.offer(packet); // fail immediately if full
         if (success) {
-            _context.simpleScheduler().addEvent(new TimeoutSyn(packet), _acceptTimeout);
+            _context.simpleTimer2().addEvent(new TimeoutSyn(packet), _acceptTimeout);
         } else {
             if (_log.shouldLog(Log.WARN))
                 _log.warn("Dropping new SYN request, as the queue is full");
diff --git a/apps/streaming/java/src/net/i2p/client/streaming/impl/MessageOutputStream.java b/apps/streaming/java/src/net/i2p/client/streaming/impl/MessageOutputStream.java
index c675812a6e..69e967f838 100644
--- a/apps/streaming/java/src/net/i2p/client/streaming/impl/MessageOutputStream.java
+++ b/apps/streaming/java/src/net/i2p/client/streaming/impl/MessageOutputStream.java
@@ -233,7 +233,7 @@ class MessageOutputStream extends OutputStream {
             // no need to be overly worried about duplicates - it would just 
             // push it further out
             if (!_enqueued) {
-                // Maybe we could just use schedule() here - or even SimpleScheduler - not sure...
+                // Maybe we could just use schedule() here - or even SimpleTimer2 - not sure...
                 // To be safe, use forceReschedule() so we don't get lots of duplicates
                 // We've seen the queue blow up before, maybe it was this before the rewrite...
                 // So perhaps it IS wise to be "overly worried" ...
diff --git a/core/java/src/net/i2p/util/ByteCache.java b/core/java/src/net/i2p/util/ByteCache.java
index dcc69d0c3d..52cab30143 100644
--- a/core/java/src/net/i2p/util/ByteCache.java
+++ b/core/java/src/net/i2p/util/ByteCache.java
@@ -69,7 +69,7 @@ public final class ByteCache {
     /**
      * Get a cache responsible for objects of the given size.
      * Warning, if you store the result in a static field, the cleaners will
-     * not operate after a restart on Android, as the old context's SimpleScheduler will have shut down.
+     * not operate after a restart on Android, as the old context's SimpleTimer2 will have shut down.
      * TODO tie this to the context or clean up all calls.
      *
      * @param cacheSize how large we want the cache to grow 
diff --git a/core/java/src/net/i2p/util/SimpleTimer.java b/core/java/src/net/i2p/util/SimpleTimer.java
index a5ad981f7b..a7626e0215 100644
--- a/core/java/src/net/i2p/util/SimpleTimer.java
+++ b/core/java/src/net/i2p/util/SimpleTimer.java
@@ -14,7 +14,7 @@ import net.i2p.I2PAppContext;
  * they b0rk the timer).
  *
  * WARNING - Deprecated.
- * This is an inefficient mess. Use SimpleScheduler or SimpleTimer2 if possible.
+ * This is an inefficient mess. Use  SimpleTimer2 if possible.
  */
 public class SimpleTimer {
 
diff --git a/router/java/src/net/i2p/router/peermanager/PeerManager.java b/router/java/src/net/i2p/router/peermanager/PeerManager.java
index 9146a881e2..bb88fed790 100644
--- a/router/java/src/net/i2p/router/peermanager/PeerManager.java
+++ b/router/java/src/net/i2p/router/peermanager/PeerManager.java
@@ -82,7 +82,7 @@ class PeerManager {
             _peersByCapability.put(Character.valueOf(Character.toLowerCase(TRACKED_CAPS.charAt(i))), new ConcurrentHashSet<Hash>());
         loadProfilesInBackground();
         ////_context.jobQueue().addJob(new EvaluateProfilesJob(_context));
-        //SimpleScheduler.getInstance().addPeriodicEvent(new Reorg(), 0, REORGANIZE_TIME);
+        //SimpleTimer2.getInstance().addPeriodicEvent(new Reorg(), 0, REORGANIZE_TIME);
         //new Reorg();
         //_context.jobQueue().addJob(new PersistProfilesJob(_context, this));
     }
diff --git a/router/java/src/net/i2p/router/transport/udp/UDPReceiver.java b/router/java/src/net/i2p/router/transport/udp/UDPReceiver.java
index c452c4b570..bc16de99cb 100644
--- a/router/java/src/net/i2p/router/transport/udp/UDPReceiver.java
+++ b/router/java/src/net/i2p/router/transport/udp/UDPReceiver.java
@@ -127,7 +127,7 @@ class UDPReceiver {
             long delay = ARTIFICIAL_DELAY_BASE + _context.random().nextInt(ARTIFICIAL_DELAY);
             if (_log.shouldLog(Log.INFO))
                 _log.info("Delay packet " + packet + " for " + delay);
-            SimpleScheduler.getInstance().addEvent(new ArtificiallyDelayedReceive(packet), delay);
+            SimpleTimer2.getInstance().addEvent(new ArtificiallyDelayedReceive(packet), delay);
             return -1;
         }
 **********/
diff --git a/router/java/src/net/i2p/router/util/DecayingHashSet.java b/router/java/src/net/i2p/router/util/DecayingHashSet.java
index 3021f517cf..ea955bcb1f 100644
--- a/router/java/src/net/i2p/router/util/DecayingHashSet.java
+++ b/router/java/src/net/i2p/router/util/DecayingHashSet.java
@@ -28,13 +28,13 @@ import net.i2p.util.Log;
  *
  * If the ArrayWrapper object in the HashSet is 50 bytes, and BloomSHA1(23, 11) is 1MB,
  * then for less than 20K entries this is smaller.
- * And this uses space proportional to traffiic, so it doesn't penalize small routers
+ * And this uses space proportional to traffic, so it doesn't penalize small routers
  * with a fixed 8MB.
  * So let's try it for the first 2 or 3, for now.
  *
- * Also, DBF is syncrhonized, and uses SimpleTimer.
+ * Also, DBF is synchronized, and uses SimpleTimer.
  * Here we use a read/write lock, with synchronization only
- * when switching double buffers, and we use SimpleScheduler.
+ * when switching double buffers, and we use SimpleTimer2.
  *
  * Yes, we could stare at stats all day, and try to calculate an acceptable
  * false-positive rate for each of the above uses, then estimate the DBF size
-- 
GitLab