Package org.ow2.clif.server.api
Interface Synchronizer
-
- All Known Implementing Classes:
Synchro,SynchroBladeInsert,SynchronizerImpl
public interface SynchronizerSupport for multiple synchronization locks designated by names, possibly with counters for the number of lock notifications.- Author:
- Bruno Dillenseger
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSYNCHRONIZER
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description longclear(java.lang.String lockName)Clear one lock.longgetCount(java.lang.String lockName)Get the number of notifications issued for the specified lockbooleangetRendezVous(java.lang.String lockName, long timeoutMs)Wait until a rendez-vous is complete, i.e.voidnotify(java.lang.String lockName)Notify the specified lock, incrementing a notification counter.voidreset()Clear all locks supported by this synchronizer.voidsetRendezVous(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.voidwait(java.lang.String lockName)Wait until the specified lock is notified at least once.booleanwait(java.lang.String lockName, long timeout_ms)Wait until the specified lock is notified at least once, or the specified time out is reachedbooleanwait(java.lang.String lockName, long timeout_ms, long occurrences)Wait until the specified lock is notified at least the specified number of times, or the specified time out is reachedbooleanwasNotified(java.lang.String lockName)Test if a lock has been notified at least oncebooleanwasNotified(java.lang.String lockName, long occurrences)Test if a lock has been notified at least the specified number of times.
-
-
-
Field Detail
-
SYNCHRONIZER
static final java.lang.String SYNCHRONIZER
- See Also:
- Constant Field Values
-
-
Method Detail
-
setRendezVous
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.- Parameters:
lockName- the lock namecount- the minimum number of notifications to wait for
-
getRendezVous
boolean getRendezVous(java.lang.String lockName, long timeoutMs) throws java.lang.InterruptedException, java.lang.IllegalArgumentExceptionWait until a rendez-vous is complete, i.e. the minimum number of notifications has been reached for this lock.- Parameters:
lockName- the lock nametimeoutMs- time out in ms. 0 means infinite time out. A negative value is not acceptable.- Returns:
- false in case of time out, true otherwise
- Throws:
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.
-
wait
void wait(java.lang.String lockName) throws java.lang.InterruptedException
Wait until the specified lock is notified at least once.- Parameters:
lockName- the lock name- Throws:
java.lang.InterruptedException- the current thread has been interrupted while waiting for the lock notification, causing this method to exit with no lock notification.
-
wait
boolean wait(java.lang.String lockName, long timeout_ms) throws java.lang.InterruptedException, java.lang.IllegalArgumentExceptionWait until the specified lock is notified at least once, or the specified time out is reached- Parameters:
lockName- the lock nametimeout_ms- time out in ms. 0 means infinite time out. A negative value is not acceptable.- Returns:
- false in case of time out, true if the otherwise
- Throws:
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.
-
wait
boolean wait(java.lang.String lockName, long timeout_ms, long occurrences) throws java.lang.InterruptedException, java.lang.IllegalArgumentExceptionWait until the specified lock is notified at least the specified number of times, or the specified time out is reached- Parameters:
lockName- the lock nametimeout_ms- time out in ms. 0 means infinite time out. A negative value is not acceptable.occurrences- the minimum number of notifications to wait for- Returns:
- false in case of time out, true otherwise
- Throws:
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.
-
notify
void notify(java.lang.String lockName)
Notify the specified lock, incrementing a notification counter.- Parameters:
lockName- the lock name
-
wasNotified
boolean wasNotified(java.lang.String lockName)
Test if a lock has been notified at least once- Parameters:
lockName- the lock name- Returns:
- true if the lock has been notified, false otherwise
-
wasNotified
boolean wasNotified(java.lang.String lockName, long occurrences)Test if a lock has been notified at least the specified number of times.- Parameters:
lockName- the lock nameoccurrences- the minimum number of notifications- Returns:
- true if the lock has been notified at least the specified number of times, false otherwise
-
getCount
long getCount(java.lang.String lockName)
Get the number of notifications issued for the specified lock- Parameters:
lockName- the lock name- Returns:
- the number of notifications issued for the specified lock. 0 means this lock is unknown by this synchronizer.
-
reset
void reset()
Clear all locks supported by this synchronizer.
-
clear
long clear(java.lang.String lockName)
Clear one lock.- Parameters:
lockName- the lock name- Returns:
- the number of notifications issued on the specified lock. 0 means this lock is unknown by this synchronizer.
-
-