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

Provides a simple interface to push items to a number of subscribers. The channel will schedule all operations on the main reactor thread for thread safe reactor operations.

This provides a convenient way for connections to consume messages from long running code in defer, without threading issues.

     channel = EM::Channel.new
     sid = channel.subscribe{ |msg| p [:got, msg] }
     channel.push('hello world')
     channel.unsubscribe(sid)

See examples/ex_channel.rb for a detailed example.

### Methods

<< new pop push subscribe unsubscribe

### Public Class methods

new()

Create a new channel

### Public Instance methods

<<(*items)

Alias for push

pop(*a, &b)

Receive exactly one message from the channel.

push(*items)

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

subscribe(*a, &b)

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

unsubscribe(name)

Removes this subscriber from the list.

[Validate]