Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Thread::Queue#pop
(?::boolish non_block, ?timeout: ::_ToF?) -> Elem?
pop(non_block=false, timeout: nil)
thread_sync.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/thread_sync.rb, line 14
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]
-