Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Thread::Queue#pop

(?::boolish non_block, ?timeout: ::_ToF?) -> E?
pop(non_block=false, timeout: nil)

Retrieves data from the queue.

If the queue is empty, the calling thread is suspended until data is pushed onto the queue. If non_block is true, the thread isn’t suspended, and ThreadError is raised.

If timeout seconds have passed and no data is available nil is returned. If timeout is 0 it returns immediately.

Ruby version changes

  1. 3.2
See also #num_waiting #push #length #shift also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1