Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-560

New TimedSemaphore class

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0
    • lang.concurrent.*
    • None

    Description

      TimedSemaphore is a specialized Semaphore implementation that also has a timing component: In a configurable time period a given number of permits is available. Threads call the semaphore's acquire() method to request a permit. When no more permits are available acquire() blocks the calling thread. At the end of the time period the permits are restored, and all blocking threads are waked up.

      The main use case for this class is to provide a convenient means for controlling the load produced by a process. When used correctly, TimedSemaphore ensures that only a given number of steps (e.g. database queries, file operations, or computations) are performed in a specific time period. This may be useful for many applications.

      More information including a usage example can be found in the Javadocs of the class. Comments or suggestions for improvements are appreciated.

      Attachments

        1. TimedSemaphore.patch
          35 kB
          Oliver Heger

        Issue Links

          Activity

            People

              Unassigned Unassigned
              oheger Oliver Heger
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: