Class 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SynchronizerImpl

        public SynchronizerImpl()
    • Method Detail

      • setRendezVous

        public void setRendezVous​(java.lang.String lockName,
                                  long count)
        Description copied from interface: Synchronizer
        Set a rendez-vous for a given lock, setting the minimum number of notifications that must be reached to complete the rendez-vous.
        Specified by:
        setRendezVous in interface Synchronizer
        Parameters:
        lockName - the lock name
        count - the minimum number of notifications to wait for
      • getRendezVous

        public boolean getRendezVous​(java.lang.String lockName,
                                     long timeoutMs)
                              throws java.lang.InterruptedException,
                                     java.lang.IllegalArgumentException
        Description copied from interface: Synchronizer
        Wait until a rendez-vous is complete, i.e. the minimum number of notifications has been reached for this lock.
        Specified by:
        getRendezVous in interface Synchronizer
        Parameters:
        lockName - the lock name
        timeoutMs - 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 notification
        java.lang.IllegalArgumentException - if the value of timeout is negative.
      • notify

        public void notify​(java.lang.String lockName)
        Description copied from interface: Synchronizer
        Notify the specified lock, incrementing a notification counter.
        Specified by:
        notify in interface Synchronizer
        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.InterruptedException
        Description copied from interface: Synchronizer
        Wait until the specified lock is notified at least once.
        Specified by:
        wait in interface Synchronizer
        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.IllegalArgumentException
        Description copied from interface: Synchronizer
        Wait until the specified lock is notified at least once, or the specified time out is reached
        Specified by:
        wait in interface Synchronizer
        Parameters:
        lockName - the lock name
        timeoutMs - 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 notification
        java.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.IllegalArgumentException
        Description copied from interface: Synchronizer
        Wait until the specified lock is notified at least the specified number of times, or the specified time out is reached
        Specified by:
        wait in interface Synchronizer
        Parameters:
        lockName - the lock name
        timeoutMs - 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 notification
        java.lang.IllegalArgumentException - if the value of timeout is negative.
      • wasNotified

        public boolean wasNotified​(java.lang.String lockName)
        Description copied from interface: Synchronizer
        Test if a lock has been notified at least once
        Specified by:
        wasNotified in interface Synchronizer
        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: Synchronizer
        Test if a lock has been notified at least the specified number of times.
        Specified by:
        wasNotified in interface Synchronizer
        Parameters:
        lockName - the lock name
        number - 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: Synchronizer
        Get the number of notifications issued for the specified lock
        Specified by:
        getCount in interface Synchronizer
        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: Synchronizer
        Clear all locks supported by this synchronizer.
        Specified by:
        reset in interface Synchronizer
      • clear

        public long clear​(java.lang.String lockName)
        Description copied from interface: Synchronizer
        Clear one lock.
        Specified by:
        clear in interface Synchronizer
        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:
        toString in class java.lang.Object