Sha256: 62c856abe76b7ebaaf4652db4fb58890b82acff983397f08797fbab05b86c0ff

Contents?: true

Size: 553 Bytes

Versions: 3

Compression:

Stored size: 553 Bytes

Contents

$:.unshift("../lib")
require 'ara'

class MySimpleActor < SimpleActor
  def receive( message )
    id = rand(10)
    puts "I'm actor #{self} with ID##{id}"
    if message.class == Fixnum
      message.times do |i|
        puts "#{id} : #{i}"
        sleep 0.5
      end
    else
      puts "Don't know what to do with your message : #{message}"
    end
  end
end

mySimpleActor = Actors.actor_of(MySimpleActor).start
mySimpleActor | 5
mySimpleActor | "Hello World!"
mySimpleActor | 7
mySimpleActor | 9

puts "Thanks actor!"
sleep 20

mySimpleActor.stop

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ara-0.0.3 examples/test_actor.rb
ara-0.0.2 examples/test_actor.rb
ara-0.0.1 examples/test_actor.rb