Class: RailsMetrics::AsyncConsumer
- Inherits:
-
Object
- Object
- RailsMetrics::AsyncConsumer
- Defined in:
- lib/rails_metrics/async_consumer.rb
Instance Attribute Summary collapse
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
- #finished? ⇒ Boolean
-
#initialize(queue = Queue.new, &block) ⇒ AsyncConsumer
constructor
A new instance of AsyncConsumer.
- #push(*args) ⇒ Object
Constructor Details
#initialize(queue = Queue.new, &block) ⇒ AsyncConsumer
Returns a new instance of AsyncConsumer.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rails_metrics/async_consumer.rb', line 16 def initialize(queue=Queue.new, &block) @off = true @block = block @queue = queue @mutex = Mutex.new @thread = Thread.new do set_void_instrumenter consume end end |
Instance Attribute Details
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
14 15 16 |
# File 'lib/rails_metrics/async_consumer.rb', line 14 def thread @thread end |
Instance Method Details
#finished? ⇒ Boolean
33 34 35 |
# File 'lib/rails_metrics/async_consumer.rb', line 33 def finished? @off end |
#push(*args) ⇒ Object
28 29 30 31 |
# File 'lib/rails_metrics/async_consumer.rb', line 28 def push(*args) @mutex.synchronize { @off = false } @queue.push(*args) end |