|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.concurrent.Semaphore brooklyn.util.mutex.SemaphoreWithOwners
public class SemaphoreWithOwners extends java.util.concurrent.Semaphore
a subclass of Semaphore which requires the same thread to release as created it, and which tracks who created and released the semaphores
Constructor Summary | |
SemaphoreWithOwners(java.lang.String name)
|
|
SemaphoreWithOwners(java.lang.String name, int permits, boolean fair)
|
Method Summary | |
---|---|
void
|
acquire()
|
void
|
acquire(int permits)
|
void
|
acquireUninterruptibly()
|
void
|
acquireUninterruptibly(int permits)
|
java.lang.String
|
getDescription()
caller supplied description |
java.lang.String
|
getName()
constructor-time supplied name |
java.util.List
|
getOwningThreads()
unmodifiable view of threads owning the permits; threads with multiple permits listed multiply |
java.util.List
|
getRequestingThreads()
unmodifiable view of threads requesting access (blocked or briefly trying to acquire); this is guaranteed to be cleared _after_ getOwners (synchronizing on this class while reading both fields will give canonical access) |
void
|
indicateCallingThreadWillRequest()
Indicate that the calling thread is going to acquire or tryAcquire, in order to set up the semaphore's isInUse() value appropriately for certain checks. |
boolean
|
isCallingThreadAnOwner()
true iff the calling thread is one of the owners |
boolean
|
isInUse()
true iff there are any owners or any requesters (callers blocked trying to acquire) |
protected void
|
onAcquired(int permits)
|
protected void
|
onReleased(int permits)
|
protected void
|
onRequestFinished()
|
protected void
|
onRequesting()
|
void
|
release()
|
void
|
release(int permits)
|
void
|
setDescription(java.lang.String description)
|
java.lang.String
|
toString()
|
boolean
|
tryAcquire()
|
boolean
|
tryAcquire(int permits)
|
boolean
|
tryAcquire(int permits, long timeout, java.util.concurrent.TimeUnit unit)
|
boolean
|
tryAcquire(long timeout, java.util.concurrent.TimeUnit unit)
|
Methods inherited from class java.util.concurrent.Semaphore | |
---|---|
java.util.concurrent.Semaphore#toString(), java.util.concurrent.Semaphore#acquire(int), java.util.concurrent.Semaphore#acquire(), java.util.concurrent.Semaphore#release(int), java.util.concurrent.Semaphore#release(), java.util.concurrent.Semaphore#isFair(), java.util.concurrent.Semaphore#hasQueuedThreads(), java.util.concurrent.Semaphore#getQueueLength(), java.util.concurrent.Semaphore#tryAcquire(long, java.util.concurrent.TimeUnit), java.util.concurrent.Semaphore#tryAcquire(int), java.util.concurrent.Semaphore#tryAcquire(int, long, java.util.concurrent.TimeUnit), java.util.concurrent.Semaphore#tryAcquire(), java.util.concurrent.Semaphore#acquireUninterruptibly(), java.util.concurrent.Semaphore#acquireUninterruptibly(int), java.util.concurrent.Semaphore#availablePermits(), java.util.concurrent.Semaphore#drainPermits(), java.util.concurrent.Semaphore#wait(), java.util.concurrent.Semaphore#wait(long), 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(), java.lang.Object#wait(long), 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() |
Constructor Detail |
---|
public SemaphoreWithOwners(java.lang.String name)
public SemaphoreWithOwners(java.lang.String name, int permits, boolean fair)
Method Detail |
---|
@Override public void acquire()
@Override public void acquire(int permits)
@Override public void acquireUninterruptibly()
@Override public void acquireUninterruptibly(int permits)
public java.lang.String getDescription()
public java.lang.String getName()
public java.util.List getOwningThreads()
public java.util.List getRequestingThreads()
public void indicateCallingThreadWillRequest()
public boolean isCallingThreadAnOwner()
public boolean isInUse()
protected void onAcquired(int permits)
protected void onReleased(int permits)
protected void onRequestFinished()
protected void onRequesting()
@Override public void release()
@Override public void release(int permits)
public void setDescription(java.lang.String description)
@Override public java.lang.String toString()
@Override public boolean tryAcquire()
@Override public boolean tryAcquire(int permits)
@Override public boolean tryAcquire(int permits, long timeout, java.util.concurrent.TimeUnit unit)
@Override public boolean tryAcquire(long timeout, java.util.concurrent.TimeUnit unit)
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.