[JGIT PATCH 02/11] Make Daemon's exportAll check not require synchronization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A volatile boolean can be read more efficiently than using a
synchronized monitor on "this", as it only requires that the
load of the boolean be examining the most recent copy from the
memory bus.  Since the value of the boolean has no further
impact on the object state, we don't need to worry about more
than ensuring we see the current value of it.

Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 .../src/org/spearce/jgit/transport/Daemon.java     |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java b/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
index d3f7b2e..7b4c138 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
@@ -67,7 +67,7 @@
 
 	private final ThreadGroup processors;
 
-	private boolean exportAll;
+	private volatile boolean exportAll;
 
 	private Map<String, Repository> exports;
 
@@ -164,7 +164,7 @@ public synchronized DaemonService getService(String name) {
 	 *         ignored.
 	 * @see #setExportAll(boolean)
 	 */
-	public synchronized boolean isExportAll() {
+	public boolean isExportAll() {
 		return exportAll;
 	}
 
@@ -180,7 +180,7 @@ public synchronized boolean isExportAll() {
 	 *
 	 * @param export
 	 */
-	public synchronized void setExportAll(final boolean export) {
+	public void setExportAll(final boolean export) {
 		exportAll = export;
 	}
 
-- 
1.6.4.rc0.117.g28cb

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]