Class: Zold::Routines
- Inherits:
-
Object
- Object
- Zold::Routines
- Defined in:
- lib/zold/routines.rb
Overview
NODE command
Instance Method Summary collapse
- #add(minutes = 1) ⇒ Object
-
#initialize(log = Log::Quiet.new) ⇒ Routines
constructor
A new instance of Routines.
- #stop ⇒ Object
Constructor Details
Instance Method Details
#add(minutes = 1) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/zold/routines.rb', line 36 def add(minutes = 1) @threads << Thread.start do VerboseThread.new(@log).run(true) do Thread.current.name = 'routines' count = 0 loop do sleep(minutes * 60) yield count count += 1 end end end end |
#stop ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/zold/routines.rb', line 50 def stop @threads.each do |t| t.exit @log.debug("#{t.name} thread stopped") end @log.info("#{@threads.count} routine threads stopped") end |