Class: Concurrent::Channel
- Includes:
- Stoppable
- Defined in:
- lib/concurrent/channel.rb
Overview
Channel is a functional programming variation of Actor, based very loosely on the MailboxProcessor agent in F#. Actor is used to create objects that receive messages from other threads then processes those messages based on the behavior of the class. Channel creates objects that receive messages and processe them using the block given at construction. Channel is implemented as a subclass of Actor and supports all message-passing methods of that class. Channel also supports pools with a shared mailbox.
Constant Summary
Constants included from Runnable
Instance Method Summary collapse
-
#initialize {|message| ... } ⇒ Channel
constructor
Initialize a new object with a block operation to be performed in response to every received message.
Methods included from Stoppable
Methods inherited from Actor
Methods included from Runnable
included, #run, #run!, #running?, #stop
Methods included from Postable
#<<, #forward, #post, #post!, #post?, #ready?
Constructor Details
#initialize {|message| ... } ⇒ Channel
Initialize a new object with a block operation to be performed in response to every received message.
44 45 46 47 48 |
# File 'lib/concurrent/channel.rb', line 44 def initialize(&block) raise ArgumentError.new('no block given') unless block_given? super() @task = block end |