Ruby TimedSemaphore
Description
A TimedSemaphore is a specialized implementation of a Semaphore that gives a number of permits in a given time frame. This gem is a Ruby implementation inspired by the Java implementation from the Apache Commons Lang package.
Installation
gem install timed_semaphore
Usage
Here is a basic example of using a TimedSemaphore:
require 'timed_semaphore'
threads = []
semaphore = TimedSemaphore.new(2, 3)
10.times do |x|
threads << Thread.new do
semaphore.acquire
puts "Thread #{x}: " + Time.now.to_s
end
end
threads.map(&:join)
Copyright
Please refer to LICENSE.