Method: Libhoney::Queueing::SizedQueueWithTimeout#push

Defined in:
lib/libhoney/queueing/sized_queue_with_timeout.rb

#push(obj, timeout = :never, &timeout_policy) ⇒ Object Also known as: enq, <<

Push something onto the queue.

Parameters:

  • obj (Object)

    the thing to add to the queue

  • timeout (Numeric, :never) (defaults to: :never)

    how long in seconds to wait for the queue to have space available or :never to wait “forever”

  • timeout_policy (#call)

    defaults to -> { raise PushTimedOut } - a lambda/Proc/callable, what to do when the timeout expires

Raises:



44
45
46
47
48
49
50
51
# File 'lib/libhoney/queueing/sized_queue_with_timeout.rb', line 44

def push(obj, timeout = :never, &timeout_policy)
  timeout_policy ||= -> { raise PushTimedOut }

  wait_for_condition(@space_available, -> { !full? }, timeout, timeout_policy) do
    @items.push(obj)
    @item_available.signal
  end
end