Class: EventMachine::Queue
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/em/queue.rb |
Overview
A cross thread, reactor scheduled, linear queue.
This class provides a simple queue abstraction on top of the reactor scheduler. It services two primary purposes:
- API sugar for stateful protocols
- Pushing processing onto the reactor thread
Class Method Summary
- .new ⇒ Queue constructor
Instance Attribute Summary
- #empty? ⇒ Boolean readonly
Instance Method Summary
-
#<<(*items)
Alias for #push.
- #num_waiting ⇒ Integer
-
#pop(*a, &b) ⇒ NilClass
Pop items off the queue, running the block on the reactor thread.
-
#push(*items)
(also: #<<)
Push items onto the queue in the reactor thread.
- #size ⇒ Integer
Constructor Details
.new ⇒ Queue
# File 'lib/em/queue.rb', line 19
def initialize @sink = [] @drain = [] @popq = [] end
Instance Attribute Details
#empty? ⇒ Boolean
(readonly)
Note:
This is a peek, it's not thread safe, and may only tend toward accuracy.
# File 'lib/em/queue.rb', line 63
def empty? @drain.empty? && @sink.empty? end
Instance Method Details
#<<(*items)
Alias for #push.
# File 'lib/em/queue.rb', line 59
alias :<< :push
#num_waiting ⇒ Integer
Note:
This is a peek at the number of jobs that are currently waiting on the Queue