Interface Synchronizer

  • All Known Implementing Classes:
    Synchro, SynchroBladeInsert, SynchronizerImpl

    public interface Synchronizer
    Support 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.String SYNCHRONIZER  
    • Method Summary

      All Methods Instance Methods Abstract 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.
      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.
      void wait​(java.lang.String lockName)
      Wait until the specified lock is notified at least once.
      boolean wait​(java.lang.String lockName, long timeout_ms)
      Wait until the specified lock is notified at least once, or the specified time out is reached
      boolean wait​(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 reached
      boolean wasNotified​(java.lang.String lockName)
      Test if a lock has been notified at least once
      boolean wasNotified​(java.lang.String lockName, long occurrences)
      Test if a lock has been notified at least the specified number of times.
    • 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 name
        count - the minimum number of notifications to wait for
      • getRendezVous

        boolean getRendezVous​(java.lang.String lockName,
                              long timeoutMs)
                       throws java.lang.InterruptedException,
                              java.lang.IllegalArgumentException
        Wait until a rendez-vous is complete, i.e. the minimum number of notifications has been reached for this lock.
        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.
      • 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.IllegalArgumentException
        Wait until the specified lock is notified at least once, or the specified time out is reached
        Parameters:
        lockName - the lock name
        timeout_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 notification
        java.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.IllegalArgumentException
        Wait until the specified lock is notified at least the specified number of times, or the specified time out is reached
        Parameters:
        lockName - the lock name
        timeout_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 notification
        java.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 name
        occurrences - 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.