From: Shawn O. Pearce Date: Sat, 11 Jul 2009 20:19:17 GMT Subject: [JGIT PATCH 02/11] Make Daemon's exportAll check not require synchronization Message-ID: <1247343566-19025-3-git-send-email-spearce@spearce.org> In-Reply-To: <1247343566-19025-2-git-send-email-spearce@spearce.org> 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 --- .../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 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