Closed noteflakes closed 2 years ago
Ruby docs:
First of all: close, closed?:
close
closed?
After the call to close completes, the following are true: closed? will return true close will be ignored. calling enq/push/<< will raise a ClosedQueueError when empty? is false, calling deq/pop/shift will return an object from the queue as usual. when empty? is true, deq(false) will not suspend the thread and will return nil. deq(true) will raise a ThreadError. ClosedQueueError is inherited from StopIteration, so that you can break loop block.
After the call to close completes, the following are true:
enq
push
<<
ClosedQueueError
empty?
deq
pop
shift
deq(false)
nil
deq(true)
ThreadError
ClosedQueueError is inherited from StopIteration, so that you can break loop block.
StopIteration
Also: any ongoing blocking call to shift/pop should return nil once the queue is closed.
Then we also have:
length
size
num_waiting
nonblock=false
Ruby docs:
First of all:
close
,closed?
:Also: any ongoing blocking call to
shift
/pop
should return nil once the queue is closed.Then we also have:
deq
- alias forshift
enq
- alias forpush
length
- alias forsize
num_waiting
- returns number of fibers currently waiting on queuedeq
/pop
should also accept an optionalnonblock=false
parameter.