Revision: 23869
Updated Code
at February 16, 2010 05:20 by sai-venkat
Updated Code
require "java" require "jetlang-0.2.0.jar" include_class "org.jetlang.fibers.ThreadFiber" include_class "org.jetlang.channels.MemoryChannel" class Arnie def initialize(channel, consumer) @channel = channel @consumer = consumer end def start on_receive = Proc.new do |message| case message when "The End" puts "I will be back..." @consumer.dispose @consumer.join when "Terminate" puts "Hastala vista baby!!!" else puts "You are terminated******" end end @channel.subscribe(@consumer, on_receive) @consumer.start end def ^(message) @channel.publish(message) end end terminator = Arnie.new(MemoryChannel.new, ThreadFiber.new) terminator.start terminator ^ "Terminate" terminator ^ "Buy me icecream" terminator ^ "The End" terminator ^ "Terminate" # Will not execute as terminator is already dead...
Revision: 23868
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 16, 2010 05:17 by sai-venkat
Initial Code
require "java" require "../deps/jetlang-0.2.0.jar" include_class "org.jetlang.fibers.ThreadFiber" include_class "org.jetlang.channels.MemoryChannel" class Arnie def initialize(channel, consumer) @channel = channel @consumer = consumer end def start on_receive = Proc.new do |message| case message when "The End" puts "I will be back..." @consumer.dispose @consumer.join when "Terminate" puts "Hastala vista baby!!!" else puts "You are terminated******" end end @channel.subscribe(@consumer, on_receive) @consumer.start end def ^(message) @channel.publish(message) end end terminator = Arnie.new(MemoryChannel.new, ThreadFiber.new) terminator.start terminator ^ "Terminate" terminator ^ "Buy me icecream" terminator ^ "The End" terminator ^ "Terminate" # Will not execute as terminator is already dead...
Initial URL
Initial Description
Initial Title
JRuby Jetlang Example
Initial Tags
Initial Language
Ruby