|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.concurrent.Semaphore groovyx.gpars.util.EnhancedSemaphore
public class EnhancedSemaphore extends java.util.concurrent.Semaphore
Extends Semaphore with a handy withSemaphore(Closure) method to safely acquire and release the Semaphore for the passed-in closure. Use: def extendedSemaphore = new ExtendedSemaphore() extendedSemaphore.withSemaphore() {* //semaphore acquired here }*
Field Summary | |
---|---|
private static long |
serialVersionUID
|
Constructor Summary | |
EnhancedSemaphore(int permits)
Creates a new EnhancedSemaphore, delegating to the Semaphore class constructor. |
Method Summary | |
---|---|
void
|
withSemaphore(groovy.lang.Closure cl)
Performs the passed-in closure with the Semaphore acquired and releases the Semaphore automatically after the closure finishes. |
Methods inherited from class java.util.concurrent.Semaphore | |
---|---|
java.util.concurrent.Semaphore#toString(), java.util.concurrent.Semaphore#acquire(), java.util.concurrent.Semaphore#acquire(int), java.util.concurrent.Semaphore#release(), java.util.concurrent.Semaphore#release(int), java.util.concurrent.Semaphore#getQueueLength(), java.util.concurrent.Semaphore#hasQueuedThreads(), java.util.concurrent.Semaphore#isFair(), java.util.concurrent.Semaphore#tryAcquire(long, java.util.concurrent.TimeUnit), java.util.concurrent.Semaphore#tryAcquire(), java.util.concurrent.Semaphore#tryAcquire(int), java.util.concurrent.Semaphore#tryAcquire(int, long, java.util.concurrent.TimeUnit), java.util.concurrent.Semaphore#acquireUninterruptibly(int), java.util.concurrent.Semaphore#acquireUninterruptibly(), java.util.concurrent.Semaphore#availablePermits(), java.util.concurrent.Semaphore#drainPermits(), java.util.concurrent.Semaphore#wait(long), java.util.concurrent.Semaphore#wait(), java.util.concurrent.Semaphore#wait(long, int), java.util.concurrent.Semaphore#equals(java.lang.Object), java.util.concurrent.Semaphore#hashCode(), java.util.concurrent.Semaphore#getClass(), java.util.concurrent.Semaphore#notify(), java.util.concurrent.Semaphore#notifyAll() |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
private static final long serialVersionUID
Constructor Detail |
---|
public EnhancedSemaphore(int permits)
permits
- Maximum number of concurrently accepted threads.
Method Detail |
---|
public void withSemaphore(groovy.lang.Closure cl)
cl
- The closure to perform with the Semaphore acquired
Copyright © 2008–2010 Václav Pech. All Rights Reserved.