Author: toad
Date: 2007-11-29 00:05:48 +0000 (Thu, 29 Nov 2007)
New Revision: 16049

Modified:
   trunk/freenet/src/freenet/node/RequestStarter.java
Log:
Refactor slightly

Modified: trunk/freenet/src/freenet/node/RequestStarter.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestStarter.java  2007-11-28 23:57:39 UTC 
(rev 16048)
+++ trunk/freenet/src/freenet/node/RequestStarter.java  2007-11-29 00:05:48 UTC 
(rev 16049)
@@ -87,23 +87,7 @@
                        if(req == null) req = sched.removeFirst();
                        if(req != null) {
                                if(logMINOR) Logger.minor(this, "Running "+req);
-                               // Create a thread to handle starting the 
request, and the resulting feedback
-                               while(true) {
-                                       try {
-                                               core.getExecutor().execute(new 
SenderThread(req), "RequestStarter$SenderThread for "+req);
-                                               if(logMINOR) Logger.minor(this, 
"Started "+req);
-                                               break;
-                                       } catch (OutOfMemoryError e) {
-                                               OOMHandler.handleOOM(e);
-                                               System.err.println("Will retry 
above failed operation...");
-                                               // Possibly out of threads
-                                               try {
-                                                       Thread.sleep(5000);
-                                               } catch (InterruptedException 
e1) {
-                                                       // Ignore
-                                               }
-                                       }
-                               }
+                               startRequest(req, logMINOR);
                                sentRequestTime = System.currentTimeMillis();
                                // Wait
                                long delay = throttle.getDelay();
@@ -141,6 +125,26 @@
                }
        }

+       private void startRequest(SendableRequest req, boolean logMINOR) {
+               // Create a thread to handle starting the request, and the 
resulting feedback
+               while(true) {
+                       try {
+                               core.getExecutor().execute(new 
SenderThread(req), "RequestStarter$SenderThread for "+req);
+                               if(logMINOR) Logger.minor(this, "Started "+req);
+                               break;
+                       } catch (OutOfMemoryError e) {
+                               OOMHandler.handleOOM(e);
+                               System.err.println("Will retry above failed 
operation...");
+                               // Possibly out of threads
+                               try {
+                                       Thread.sleep(5000);
+                               } catch (InterruptedException e1) {
+                                       // Ignore
+                               }
+                       }
+               }
+       }
+
        public void run() {
            freenet.support.Logger.OSThread.logPID(this);
                while(true) {


Reply via email to