[jboss-cvs] JBoss Messaging SVN: r3230 - trunk/src/main/org/jboss/messaging/util.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Oct 20 14:17:30 EDT 2007
Author: timfox
Date: 2007-10-20 14:17:30 -0400 (Sat, 20 Oct 2007)
New Revision: 3230
Modified:
trunk/src/main/org/jboss/messaging/util/ClearableSemaphore.java
Log:
Another adjustment to semaphore
Modified: trunk/src/main/org/jboss/messaging/util/ClearableSemaphore.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/ClearableSemaphore.java 2007-10-20 17:58:13 UTC (rev 3229)
+++ trunk/src/main/org/jboss/messaging/util/ClearableSemaphore.java 2007-10-20 18:17:30 UTC (rev 3230)
@@ -16,17 +16,13 @@
{
protected Logger log = Logger.getLogger(ClearableSemaphore.class);
- private Semaphore semaphore;
+ private volatile Semaphore semaphore;
- private volatile boolean enabled;
-
private int permits;
private void createSemaphore()
{
semaphore = new Semaphore(permits, true);
-
- enabled = true;
}
public ClearableSemaphore(int permits)
@@ -40,7 +36,7 @@
{
Semaphore sem = semaphore;
- if (enabled && sem != null)
+ if (sem != null)
{
sem.acquire();
}
@@ -50,7 +46,7 @@
{
Semaphore sem = semaphore;
- if (enabled && sem != null)
+ if (sem != null)
{
sem.release();
}
@@ -58,11 +54,9 @@
public synchronized void enable()
{
- if (!enabled)
+ if (semaphore == null)
{
createSemaphore();
-
- enabled = true;
}
}
@@ -71,13 +65,11 @@
// In which case we don't want to acquire a token since we might end up locking and using up all permits
public synchronized void disable()
{
- if (enabled)
+ if (semaphore != null)
{
semaphore.release(permits);
semaphore = null;
-
- enabled = false;
}
}
}
More information about the jboss-cvs-commits
mailing list