|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.concurrent.Semaphore
gpars.util.EnhancedSemaphore
class EnhancedSemaphore extends 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 }*
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 Semaphore | |
---|---|
toString, isFair, hasQueuedThreads, getQueueLength, release, release, tryAcquire, tryAcquire, tryAcquire, tryAcquire, acquire, acquire, acquireUninterruptibly, acquireUninterruptibly, availablePermits, drainPermits, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll |
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Constructor Detail |
---|
public EnhancedSemaphore(int permits)
Method Detail |
---|
public void withSemaphore(groovy.lang.Closure cl)
Groovy Documentation