Sha256: 03fa8f627d8ededfafe2aad7b5552bd5a701690e945c5b8a5c7ea8ed7936bc4b
Contents?: true
Size: 1004 Bytes
Versions: 2
Compression:
Stored size: 1004 Bytes
Contents
module Backport module Server # A Backport periodical interval server. # class Interval < Base # @param period [Float] The interval time in seconds. # @param block [Proc] The proc to run on each interval. # @yieldparam [Interval] def initialize period, &block @period = period @block = block @ready = false @mutex = Mutex.new end def starting @ready = false run_ready_thread end def tick return unless @ready @mutex.synchronize do @block.call self @ready = false end end private # @return [void] def run_ready_thread Thread.new do until stopped? sleep @period break if stopped? @mutex.synchronize { @ready = true } changed notify_observers self end end end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
getargv-0.3.3-universal-darwin | vendor/bundle/ruby/3.3.0/gems/backport-1.2.0/lib/backport/server/interval.rb |
backport-1.2.0 | lib/backport/server/interval.rb |