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)
thread_sync.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/thread_sync.rb, line 71
def pop(non_block = false, timeout: nil)
if non_block && timeout
raise ArgumentError, "can't set a timeout if non_block is enabled"
end
Primitive.rb_queue_pop(non_block, timeout)
end
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
-
3.2
-
Thread::Queue#pop(timeout: sec) is added. [Feature #18774]
-