incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bcur...@apache.org
Subject git commit: Fix CB-135 Multithreaded access on CallbackServer javascript object.
Date Sat, 07 Jan 2012 04:24:02 GMT
Updated Branches:
  refs/heads/master bc309c9f0 -> 8db5e06c6


Fix  CB-135 Multithreaded access on CallbackServer javascript object.


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/8db5e06c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/8db5e06c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/8db5e06c

Branch: refs/heads/master
Commit: 8db5e06c625b129aa80c006788d25e239a0fdb09
Parents: bc309c9
Author: Bryce Curtis <curtis.bryce@gmail.com>
Authored: Fri Jan 6 22:23:49 2012 -0600
Committer: Bryce Curtis <curtis.bryce@gmail.com>
Committed: Fri Jan 6 22:23:49 2012 -0600

----------------------------------------------------------------------
 framework/src/com/phonegap/CallbackServer.java |   39 +++++++++----------
 1 files changed, 19 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/8db5e06c/framework/src/com/phonegap/CallbackServer.java
----------------------------------------------------------------------
diff --git a/framework/src/com/phonegap/CallbackServer.java b/framework/src/com/phonegap/CallbackServer.java
index 81e5800..d459d99 100755
--- a/framework/src/com/phonegap/CallbackServer.java
+++ b/framework/src/com/phonegap/CallbackServer.java
@@ -314,9 +314,10 @@ public class CallbackServer implements Runnable {
 	 * @return int
 	 */
 	public int getSize() {
-		int size = this.javascript.size();
-		//System.out.println("getSize() = " + size);
-		return size;
+	    synchronized(this) {
+	        int size = this.javascript.size();
+	        return size;
+	    }
 	}
 	
 	/**
@@ -325,17 +326,16 @@ public class CallbackServer implements Runnable {
 	 * @return String
 	 */
 	public String getJavascript() {
-		if (this.javascript.size() == 0) {
-			return null;
-		}
-		String statement = this.javascript.remove(0);
-		//System.out.println("CallbackServer.getJavascript() = " + statement);
-		if (this.javascript.size() == 0) {
-			synchronized (this) { 
-				this.empty = true;
-			}
-		}
-		return statement;
+	    synchronized(this) {
+	        if (this.javascript.size() == 0) {
+	            return null;
+	        }
+	        String statement = this.javascript.remove(0);
+	        if (this.javascript.size() == 0) { 
+	            this.empty = true;
+	        }
+	        return statement;
+	    }
 	}
 	
 	/**
@@ -344,12 +344,11 @@ public class CallbackServer implements Runnable {
 	 * @param statement
 	 */
 	public void sendJavascript(String statement) {
-		//System.out.println("CallbackServer.sendJavascript("+statement+")");
-		this.javascript.add(statement);
-		synchronized (this) { 
-			this.empty = false;
-			this.notify();
-		}
+	    synchronized (this) { 
+	        this.javascript.add(statement);
+	        this.empty = false;
+	        this.notify();
+	    }
 	}
 	
 	/* The Following code has been modified from original implementation of URLEncoder */


Mime
View raw message