Class EventMachine::Queue
In: lib/em/queue.rb
Parent: Object

A cross thread, reactor scheduled, linear queue.

This class provides a simple "Queue" like abstraction on top of the reactor scheduler. It services two primary purposes:

  • API sugar for stateful protocols
  • Pushing processing onto the same thread as the reactor

See examples/ex_queue.rb for a detailed example.

 q = EM::Queue.new
 q.push('one', 'two', 'three')
 3.times do
   q.pop{ |msg| puts(msg) }
 end

Methods

empty?   new   pop   push   size  

Public Class methods

Create a new queue

Public Instance methods

N.B. This is a peek, it‘s not thread safe, and may only tend toward accuracy.

Pop items off the queue, running the block on the reactor thread. The pop will not happen immediately, but at some point in the future, either in the next tick, if the queue has data, or when the queue is populated.

Push items onto the queue in the reactor thread. The items will not appear in the queue immediately, but will be scheduled for addition during the next reactor tick.

N.B. This is a peek, it‘s not thread safe, and may only tend toward accuracy.

[Validate]