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.
3 4 5 |
# File 'lib/logster/scheduler.rb', line 3 def queue @queue end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
3 4 5 |
# File 'lib/logster/scheduler.rb', line 3 def thread @thread end |
Instance Method Details
#disable ⇒ Object
11 12 13 |
# File 'lib/logster/scheduler.rb', line 11 def disable @enabled = false end |
#enable ⇒ Object
15 16 17 |
# File 'lib/logster/scheduler.rb', line 15 def enable @enabled = true end |
#initialize ⇒ Object
4 5 6 7 8 9 |
# File 'lib/logster/scheduler.rb', line 4 def initialize @queue = Queue.new @mutex = Mutex.new @thread = nil @enabled = true end |
#schedule(&blk) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/logster/scheduler.rb', line 19 def schedule(&blk) if @enabled start_thread if !@thread&.alive? @queue << blk else return if blk == :terminate blk.call end end |