| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.concurrent.Semaphore
groovyx.gpars.util.EnhancedSemaphore
public class EnhancedSemaphore
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 | 
|---|
acquire, acquire, acquireUninterruptibly, acquireUninterruptibly, availablePermits, drainPermits, getQueuedThreads, getQueueLength, hasQueuedThreads, isFair, reducePermits, release, release, toString, tryAcquire, tryAcquire, tryAcquire, tryAcquire | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| 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)
                   throws java.lang.InterruptedException
cl - The closure to perform with the Semaphore acquired
java.lang.InterruptedException - If the current thread gets interrupted
  | 
Copyright © 2008–2010 Václav Pech. All Rights Reserved. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||