Author: toad
Date: 2008-07-04 13:18:19 +0000 (Fri, 04 Jul 2008)
New Revision: 20971

Modified:
   branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
Log:
finishRegister() onDatabaseThread parameter:
- Should be true in self-contained database jobs.
- Should be false in some cases where register() is called many times in a loop 
(e.g. SplitFileInserter.schedule()).
- Should be passed through for non-persistent requests.

Modified: 
branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2008-07-04 13:05:42 UTC (rev 20970)
+++ branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2008-07-04 13:18:19 UTC (rev 20971)
@@ -195,7 +195,7 @@
                                if(probablyNotInStore) {
                                        // Complete the registration *before* 
checking the store.
                                        // Check the store anyway though!
-                                       finishRegister(req, persistent, false, 
true, reg);
+                                       finishRegister(req, persistent, true, 
true, reg);
                                        // RegisterMe has been deleted or was 
null in the first place.
                                        reg = null;
                                } else {
@@ -228,7 +228,7 @@
                                                if(probablyNotInStore) {
                                                        // Complete the 
registration *before* checking the store.
                                                        // Check the store 
anyway though!
-                                                       finishRegister(req, 
persistent, false, true, reg);
+                                                       finishRegister(req, 
persistent, true, true, reg);
                                                        // RegisterMe has been 
deleted or was null in the first place.
                                                        reg = null;
                                                } else {
@@ -275,6 +275,9 @@
                        if(persistent) {
                                if(onDatabaseThread) {
                                        schedCore.queueRegister(req, 
databaseExecutor, selectorContainer);
+                                       // Pretend to not be on the database 
thread.
+                                       // In some places (e.g. 
SplitFileInserter.start(), we call register() *many* times within a single 
transaction.
+                                       // We can greatly improve 
responsiveness at the cost of some throughput and RAM by only adding the tags 
at this point.
                                        finishRegister(req, persistent, false, 
true, reg);
                                } else {
                                        final RegisterMe regme = reg;
@@ -285,16 +288,14 @@
                                                        RegisterMe reg = regme;
                                                        if(reg == null)
                                                                reg = 
schedCore.queueRegister(req, databaseExecutor, selectorContainer);
-                                                       // Pretend to not be on 
the database thread.
-                                                       // In some places (e.g. 
SplitFileInserter.start(), we call register() *many* times within a single 
transaction.
-                                                       // We can greatly 
improve responsiveness at the cost of some throughput and RAM by only adding 
the tags at this point.
-                                                       finishRegister(req, 
persistent, false, true, reg);
+                                                       // Self-contained job, 
will complete quickly enough.
+                                                       finishRegister(req, 
persistent, true, true, reg);
                                                }

                                        }, NativeThread.NORM_PRIORITY, false);
                                }
                        } else {
-                               finishRegister(req, persistent, false, true, 
reg);
+                               finishRegister(req, persistent, 
onDatabaseThread, true, reg);
                        }
                }
        }


Reply via email to