Sha256: 7f8b097fd222714b72d05f7b1d164f77b09d02d93fff18e1398b9e81d4a35052

Contents?: true

Size: 498 Bytes

Versions: 6

Compression:

Stored size: 498 Bytes

Contents

# encoding: utf-8

module Kurchatov
  class Queue
    QUEUE_MAX_SIZE = 100

    def initialize
      @events = ::Queue.new
    end

    def <<(event)
      if @events.size >= QUEUE_MAX_SIZE
        drop = @events.shift
        Log.error("Drop event: #{drop.inspect}. See Kurchatov::Queue::QUEUE_MAX_SIZE")
      end
      @events << event
    end

    def all
      cur_events = Array.new
      until @events.empty?
        cur_events << @events.shift
      end
      cur_events
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kurchatov-0.0.3 lib/kurchatov/queue.rb
kurchatov-0.0.3b lib/kurchatov/queue.rb
kurchatov-0.0.3a lib/kurchatov/queue.rb
kurchatov-0.0.2 lib/kurchatov/queue.rb
kurchatov-0.0.2b lib/kurchatov/queue.rb
kurchatov-0.0.1 lib/kurchatov/queue.rb