Package org.ow2.clif.server.lib
Class SynchronizerImpl
- java.lang.Object
-
- org.ow2.clif.server.lib.SynchronizerImpl
-
- All Implemented Interfaces:
Synchronizer
- Direct Known Subclasses:
SynchroBladeInsert
public class SynchronizerImpl extends java.lang.Object implements Synchronizer
Just a plain implementation of Synchronizer interface. Refer to the Synchronizer interface documentation.- Author:
- Bruno Dillenseger
- See Also:
Synchronizer
-
-
Field Summary
-
Fields inherited from interface org.ow2.clif.server.api.Synchronizer
SYNCHRONIZER
-
-
Constructor Summary
Constructors Constructor Description SynchronizerImpl()
-
Method Summary
All Methods Instance Methods Concrete 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.protected voidnewLock(java.lang.String lockName)Does nothing.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.java.lang.StringtoString()voidwait(java.lang.String lockName)Wait until the specified lock is notified at least once.booleanwait(java.lang.String lockName, long timeoutMs)Wait until the specified lock is notified at least once, or the specified time out is reachedbooleanwait(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 reachedbooleanwasNotified(java.lang.String lockName)Test if a lock has been notified at least oncebooleanwasNotified(java.lang.String lockName, long number)Test if a lock has been notified at least the specified number of times.
-
-
-
Method Detail
-
setRendezVous
public void setRendezVous(java.lang.String lockName, long count)Description copied from interface:SynchronizerSet a rendez-vous for a given lock, setting the minimum number of notifications that must be reached to complete the rendez-vous.- Specified by:
setRendezVousin interfaceSynchronizer- Parameters:
lockName- the lock namecount- the minimum number of notifications to wait for
-
getRendezVous
public boolean getRendezVous(java.lang.String lockName, long timeoutMs) throws java.lang.InterruptedException, java.lang.IllegalArgumentExceptionDescription copied from interface:SynchronizerWait until a rendez-vous is complete, i.e. the minimum number of notifications has been reached for this lock.- Specified by:
getRendezVousin interfaceSynchronizer- 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.
-
notify
public void notify(java.lang.String lockName)
Description copied from interface:SynchronizerNotify the specified lock, incrementing a notification counter.- Specified by:
notifyin interfaceSynchronizer- Parameters:
lockName- the lock name
-
newLock
protected void newLock(java.lang.String lockName)
Does nothing. Override this method as a call-back to be informed when a lock is notified for the first time.- Parameters:
lockName- the name of the new lock
-
wait
public void wait(java.lang.String lockName) throws java.lang.InterruptedExceptionDescription copied from interface:SynchronizerWait until the specified lock is notified at least once.- Specified by:
waitin interfaceSynchronizer- 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
public boolean wait(java.lang.String lockName, long timeoutMs) throws java.lang.InterruptedException, java.lang.IllegalArgumentExceptionDescription copied from interface:SynchronizerWait until the specified lock is notified at least once, or the specified time out is reached- Specified by:
waitin interfaceSynchronizer- 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 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
public boolean wait(java.lang.String lockName, long timeoutMs, long number) throws java.lang.InterruptedException, java.lang.IllegalArgumentExceptionDescription copied from interface:SynchronizerWait until the specified lock is notified at least the specified number of times, or the specified time out is reached- Specified by:
waitin interfaceSynchronizer- Parameters:
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 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.
-
wasNotified
public boolean wasNotified(java.lang.String lockName)
Description copied from interface:SynchronizerTest if a lock has been notified at least once- Specified by:
wasNotifiedin interfaceSynchronizer- Parameters:
lockName- the lock name- Returns:
- true if the lock has been notified, false otherwise
-
wasNotified
public boolean wasNotified(java.lang.String lockName, long number)Description copied from interface:SynchronizerTest if a lock has been notified at least the specified number of times.- Specified by:
wasNotifiedin interfaceSynchronizer- Parameters:
lockName- the lock namenumber- the minimum number of notifications- Returns:
- true if the lock has been notified at least the specified number of times, false otherwise
-
getCount
public long getCount(java.lang.String lockName)
Description copied from interface:SynchronizerGet the number of notifications issued for the specified lock- Specified by:
getCountin interfaceSynchronizer- 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
public void reset()
Description copied from interface:SynchronizerClear all locks supported by this synchronizer.- Specified by:
resetin interfaceSynchronizer
-
clear
public long clear(java.lang.String lockName)
Description copied from interface:SynchronizerClear one lock.- Specified by:
clearin interfaceSynchronizer- Parameters:
lockName- the lock name- Returns:
- the number of notifications issued on the specified lock. 0 means this lock is unknown by this synchronizer.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-