Class: JRL::Channel

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/jretlang/channel.rb

Instance Method Summary collapse

Constructor Details

#initializeChannel

Returns a new instance of Channel.



2
3
4
5
# File 'lib/jretlang/channel.rb', line 2

def initialize
  @mc = JRL::Channels::MemoryChannel.new
  super( @mc ) 
end

Instance Method Details

#subscribe_on_fiber(fiber, &block) ⇒ Object



7
8
9
# File 'lib/jretlang/channel.rb', line 7

def subscribe_on_fiber( fiber, &block )
  @mc.subscribe( strip_delegate( fiber ), &block )
end

#subscribe_on_fiber_with_batch(fiber, time, time_unit = JRL::Concurrent::TimeUnit::SECONDS, &block) ⇒ Object



16
17
18
19
# File 'lib/jretlang/channel.rb', line 16

def subscribe_on_fiber_with_batch( fiber, time, time_unit=JRL::Concurrent::TimeUnit::SECONDS, &block )
  batch = JRL::Channels::BatchSubscriber.new( strip_delegate( fiber ), block, time, time_unit )
  @mc.subscribe( batch )
end

#subscribe_on_fiber_with_batch_and_key(fiber, key_lambda, time, time_unit = JRL::Concurrent::TimeUnit::SECONDS, &block) ⇒ Object



21
22
23
24
# File 'lib/jretlang/channel.rb', line 21

def subscribe_on_fiber_with_batch_and_key( fiber, key_lambda, time, time_unit=JRL::Concurrent::TimeUnit::SECONDS, &block )
  batch = JRL::Channels::KeyedBatchSubscriber.new( strip_delegate( fiber ), block, time, time_unit, key_lambda )
  @mc.subscribe( batch )
end

#subscribe_on_fiber_with_filter(fiber, filter_lambda, &block) ⇒ Object



11
12
13
14
# File 'lib/jretlang/channel.rb', line 11

def subscribe_on_fiber_with_filter( fiber, filter_lambda, &block )
  subscription = JRL::Channels::ChannelSubscription.new( strip_delegate( fiber ), block, filter_lambda )
  @mc.subscribe( subscription )
end