Class: Zipkin::Collector::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/zipkin/collector.rb

Instance Method Summary collapse

Constructor Details

#initializeBuffer

Returns a new instance of Buffer.



50
51
52
53
# File 'lib/zipkin/collector.rb', line 50

def initialize
  @buffer = []
  @mutex = Mutex.new
end

Instance Method Details

#<<(element) ⇒ Object



55
56
57
58
59
60
# File 'lib/zipkin/collector.rb', line 55

def <<(element)
  @mutex.synchronize do
    @buffer << element
    true
  end
end

#retrieveObject



62
63
64
65
66
67
68
# File 'lib/zipkin/collector.rb', line 62

def retrieve
  @mutex.synchronize do
    elements = @buffer.dup
    @buffer.clear
    elements
  end
end