Method: Fluent::Plugin::Buffer#dequeue_chunk

Defined in:
lib/fluent/plugin/buffer.rb

#dequeue_chunkObject



557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
# File 'lib/fluent/plugin/buffer.rb', line 557

def dequeue_chunk
  return nil if @queue.empty?
  log.on_trace { log.trace "dequeueing a chunk", instance: self.object_id }

  synchronize do
    chunk = @queue.shift

    # this buffer is dequeued by other thread just before "synchronize" in this thread
    return nil unless chunk

    @dequeued[chunk.unique_id] = chunk
    @queued_num[chunk.] -= 1 # BUG if nil, 0 or subzero
    @dequeued_num[chunk.] ||= 0
    @dequeued_num[chunk.] += 1
    log.trace "chunk dequeued", instance: self.object_id, metadata: chunk.
    chunk
  end
end