public class SynchronizerImpl extends java.lang.Object implements Synchronizer
Synchronizer
SYNCHRONIZER
Constructor and Description |
---|
SynchronizerImpl() |
Modifier and Type | Method and Description |
---|---|
long |
clear(java.lang.String lockName)
Clear one lock.
|
long |
getCount(java.lang.String lockName)
Get the number of notifications issued for the specified lock
|
boolean |
getRendezVous(java.lang.String lockName,
long timeoutMs)
Wait until a rendez-vous is complete, i.e.
|
protected void |
newLock(java.lang.String lockName)
Does nothing.
|
void |
notify(java.lang.String lockName)
Notify the specified lock, incrementing a notification counter.
|
void |
reset()
Clear all locks supported by this synchronizer.
|
void |
setRendezVous(java.lang.String lockName,
long count)
Set a rendez-vous for a given lock, setting the minimum
number of notifications that must be reached to complete
the rendez-vous.
|
java.lang.String |
toString() |
void |
wait(java.lang.String lockName)
Wait until the specified lock is notified at least once.
|
boolean |
wait(java.lang.String lockName,
long timeoutMs)
Wait until the specified lock is notified at least once,
or the specified time out is reached
|
boolean |
wait(java.lang.String lockName,
long timeoutMs,
long number)
Wait until the specified lock is notified at least the specified
number of times, or the specified time out is reached
|
boolean |
wasNotified(java.lang.String lockName)
Test if a lock has been notified at least once
|
boolean |
wasNotified(java.lang.String lockName,
long number)
Test if a lock has been notified at least the specified
number of times.
|
public void setRendezVous(java.lang.String lockName, long count)
Synchronizer
setRendezVous
in interface Synchronizer
lockName
- the lock namecount
- the minimum number of notifications to wait forpublic boolean getRendezVous(java.lang.String lockName, long timeoutMs) throws java.lang.InterruptedException, java.lang.IllegalArgumentException
Synchronizer
getRendezVous
in interface Synchronizer
lockName
- the lock nametimeoutMs
- time out in ms. 0 means infinite time out.
A negative value is not acceptable.java.lang.InterruptedException
- if any thread interrupted the current
thread before or while the current thread was waiting for a notificationjava.lang.IllegalArgumentException
- if the value of timeout is negative.public void notify(java.lang.String lockName)
Synchronizer
notify
in interface Synchronizer
lockName
- the lock nameprotected void newLock(java.lang.String lockName)
lockName
- the name of the new lockpublic void wait(java.lang.String lockName) throws java.lang.InterruptedException
Synchronizer
wait
in interface Synchronizer
lockName
- the lock namejava.lang.InterruptedException
- the current thread has been interrupted
while waiting for the lock notification, causing this method to exit
with no lock notification.public boolean wait(java.lang.String lockName, long timeoutMs) throws java.lang.InterruptedException, java.lang.IllegalArgumentException
Synchronizer
wait
in interface Synchronizer
lockName
- the lock nametimeoutMs
- time out in ms. 0 means infinite time out.
A negative value is not acceptable.java.lang.InterruptedException
- if any thread interrupted the current
thread before or while the current thread was waiting for a notificationjava.lang.IllegalArgumentException
- if the value of timeout is negative.public boolean wait(java.lang.String lockName, long timeoutMs, long number) throws java.lang.InterruptedException, java.lang.IllegalArgumentException
Synchronizer
wait
in interface Synchronizer
lockName
- the lock nametimeoutMs
- time out in ms. 0 means infinite time out.
A negative value is not acceptable.number
- the minimum number of notifications to wait forjava.lang.InterruptedException
- if any thread interrupted the current
thread before or while the current thread was waiting for a notificationjava.lang.IllegalArgumentException
- if the value of timeout is negative.public boolean wasNotified(java.lang.String lockName)
Synchronizer
wasNotified
in interface Synchronizer
lockName
- the lock namepublic boolean wasNotified(java.lang.String lockName, long number)
Synchronizer
wasNotified
in interface Synchronizer
lockName
- the lock namenumber
- the minimum number of notificationspublic long getCount(java.lang.String lockName)
Synchronizer
getCount
in interface Synchronizer
lockName
- the lock namepublic void reset()
Synchronizer
reset
in interface Synchronizer
public long clear(java.lang.String lockName)
Synchronizer
clear
in interface Synchronizer
lockName
- the lock namepublic java.lang.String toString()
toString
in class java.lang.Object