Class: Zipkin::AsyncReporter::Buffer
- Inherits:
-
Object
- Object
- Zipkin::AsyncReporter::Buffer
- Defined in:
- lib/zipkin/async_reporter/buffer.rb
Instance Method Summary collapse
- #<<(element) ⇒ Object
-
#initialize ⇒ Buffer
constructor
A new instance of Buffer.
- #retrieve ⇒ Object
Constructor Details
#initialize ⇒ Buffer
Returns a new instance of Buffer.
6 7 8 9 |
# File 'lib/zipkin/async_reporter/buffer.rb', line 6 def initialize @buffer = [] @mutex = Mutex.new end |
Instance Method Details
#<<(element) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/zipkin/async_reporter/buffer.rb', line 11 def <<(element) @mutex.synchronize do @buffer << element true end end |
#retrieve ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/zipkin/async_reporter/buffer.rb', line 18 def retrieve @mutex.synchronize do elements = @buffer.dup @buffer.clear elements end end |