Module: Logster::Deferer
- Included in:
- Scheduler
- Defined in:
- lib/logster/scheduler.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
5 6 7 |
# File 'lib/logster/scheduler.rb', line 5 def queue @queue end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
5 6 7 |
# File 'lib/logster/scheduler.rb', line 5 def thread @thread end |
Instance Method Details
#disable ⇒ Object
13 14 15 |
# File 'lib/logster/scheduler.rb', line 13 def disable @enabled = false end |
#enable ⇒ Object
17 18 19 |
# File 'lib/logster/scheduler.rb', line 17 def enable @enabled = true end |
#initialize ⇒ Object
6 7 8 9 10 11 |
# File 'lib/logster/scheduler.rb', line 6 def initialize @queue = Queue.new @mutex = Mutex.new @thread = nil @enabled = true end |
#schedule(&blk) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/logster/scheduler.rb', line 21 def schedule(&blk) if @enabled start_thread if !@thread&.alive? @queue << blk else return if blk == :terminate blk.call end end |