Permalink
Browse files

refactoring some examples

  • Loading branch information...
1 parent 2f6ca5f commit 5950cd2a897167acb6f59f83b2928494a57db370 @danielribeiro committed Dec 17, 2010
Showing with 14 additions and 16 deletions.
  1. +8 −1 lib/akka.rb
  2. +2 −4 lib/everything_is_an_actor.rb
  3. +2 −4 lib/fixxed_basic_example.rb
  4. +2 −6 lib/proc_basic_example.rb
  5. +0 −1 lib/wont_work_without_create.rb
View
@@ -63,9 +63,16 @@ def method_missing(name, *args, &block)
end
end
+ extend self
+ def delayedShutdown(seconds)
+ sleep seconds
+ shutdown
+ end
+ def shutdown
+ Akka::ActorRegistry.shutdownAll
+ end
- extend self
def spawn(&block)
BlockActor.spawn block
end
@@ -4,7 +4,5 @@ def hi
puts "hello actor world"
end
end
-o = Actors.actorOf HelloWord.new
-o.hi
-sleep 1
-Akka::ActorRegistry.shutdownAll
+Actors.actorOf(HelloWord.new).hi
+Actors.delayedShutdown 1
@@ -4,7 +4,5 @@ def onReceive(message)
puts "!!! Acted on: #{message}"
end
end
-actor = PingActor.spawn
-actor.sendOneWay "hello actor world"
-sleep 1
-Akka::ActorRegistry.shutdownAll
+PingActor.spawn.sendOneWay "hello actor world"
+Actors.delayedShutdown 1
@@ -1,7 +1,3 @@
require 'akka'
-actor = Actors.spawn do |message|
- puts "!!! Acted on: #{message}"
-end
-actor.sendOneWay "hello actor world"
-sleep 1
-Akka::ActorRegistry.shutdownAll
+Actors.spawn { |m| puts "!!! Acted on: #{m}" }.sendOneWay "hello actor world"
+Actors.delayedShutdown 1
@@ -27,6 +27,5 @@ def onReceive(message)
actor = Akka::UntypedActor.actorOf { PingActor.new('lala') }.start()
actor.sendOneWay("hello actor world")
-require 'pp'
sleep 1
Akka::ActorRegistry.shutdownAll()

0 comments on commit 5950cd2

Please sign in to comment.