incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [6/14] android commit: Use a thread pool when executing async plugin operations.
Date Tue, 18 Sep 2012 17:52:51 GMT
Use a thread pool when executing async plugin operations.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/18893bf6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/18893bf6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/18893bf6

Branch: refs/heads/master
Commit: 18893bf6cd32e05892c262679eff2adb0868e772
Parents: f53161d
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Tue Sep 11 14:36:25 2012 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Sep 18 13:24:37 2012 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/api/PluginManager.java  |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/18893bf6/framework/src/org/apache/cordova/api/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/PluginManager.java b/framework/src/org/apache/cordova/api/PluginManager.java
index 99b8aeb..3230b57 100755
--- a/framework/src/org/apache/cordova/api/PluginManager.java
+++ b/framework/src/org/apache/cordova/api/PluginManager.java
@@ -22,6 +22,8 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map.Entry;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 import org.apache.cordova.CordovaWebView;
 import org.json.JSONArray;
@@ -45,6 +47,7 @@ public class PluginManager {
 
     private final CordovaInterface ctx;
     private final CordovaWebView app;
+    private final ExecutorService execThreadPool = Executors.newCachedThreadPool();
 
     // Flag to track first time through
     private boolean firstRun;
@@ -222,7 +225,7 @@ public class PluginManager {
                 runAsync = async && !plugin.isSynch(action);
                 if (runAsync) {
                     // Run this on a different thread so that this one can return back to
JS
-                    Thread thread = new Thread(new Runnable() {
+                    execThreadPool.execute(new Runnable() {
                         public void run() {
                             try {
                                 // Call execute on the plugin so that it can do it's thing
@@ -234,7 +237,6 @@ public class PluginManager {
                             }
                         }
                     });
-                    thread.start();
                     return;
                 } else {
                     // Call execute on the plugin so that it can do it's thing


Mime
View raw message