Class EventMachine::Channel
In: lib/em/channel.rb
Parent: Object

Provides a simple thread-safe way to transfer data between (typically) long running tasks in {EventMachine.defer} and event loop thread.

@example

 channel = EventMachine::Channel.new
 sid     = channel.subscribe { |msg| p [:got, msg] }

 channel.push('hello world')
 channel.unsubscribe(sid)

Methods

<<   new   pop   push   subscribe   unsubscribe  

Public Class methods

Public Instance methods

<<(*items)

Alias for push

Fetches one message from the channel.

Add items to the channel, which are pushed out to all subscribers.

Takes any arguments suitable for EM::Callback() and returns a subscriber id for use when unsubscribing.

@return [Integer] Subscribe identifier @see unsubscribe

Removes subscriber from the list.

@param [Integer] Subscriber identifier @see subscribe

[Validate]