Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Thread::SizedQueue#enq

enq(object, non_block=false, timeout: nil)

Alias of #push

Pushes object to the queue.

If there is no space left in the queue, waits until space becomes available, unless non_block is true. If non_block is true, the thread isn’t suspended, and ThreadError is raised.

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

See also #push #empty? #length #deq also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1