Class: Backport::Server::Interval
- Defined in:
- lib/backport/server/interval.rb
Overview
A Backport periodical interval server.
Instance Method Summary collapse
-
#initialize(period, &block) {|| ... } ⇒ Interval
constructor
A new instance of Interval.
- #starting ⇒ Object
- #tick ⇒ Object
Methods inherited from Base
#start, #started?, #stop, #stopped?, #stopping
Constructor Details
#initialize(period, &block) {|| ... } ⇒ Interval
Returns a new instance of Interval.
9 10 11 12 13 14 |
# File 'lib/backport/server/interval.rb', line 9 def initialize period, &block @period = period @block = block @ready = false @mutex = Mutex.new end |
Instance Method Details
#starting ⇒ Object
16 17 18 19 |
# File 'lib/backport/server/interval.rb', line 16 def starting @ready = false run_ready_thread end |
#tick ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/backport/server/interval.rb', line 21 def tick return unless @ready @mutex.synchronize do @block.call self @ready = false end end |