From: Marcin Raczkowski Date: 2007-09-22T01:44:21+09:00 Subject: Re: how about actors implemented in ruby-core itself MenTaLguY wrote: > On Fri, 2007-09-21 at 08:55 +0900, MenTaLguY wrote: >> Actor.current # => actor >> >> Returns the current actor > > One additional note -- every ruby thread has an actor > associated with it, even those which weren't created > as a result of Actor.spawn. This is implicit in the > example I gave, but I did want to make it clear. > > -mental I implemented something similar using DRb, it's slower, but you can distribute it between diffirent nodes in network. I'm in process of refactoring these classes and releasing them. right now sample app looks like: me = Keke.new me.on :dance, :response do |msg| puts "actor finished dancing and shouted "+msg.to_s end me.on :dance, :progress do |msg| puts "actor is dancing" end me.on :dance, :error do |msg| puts "actor triped and fell and screamed "+msg.to_s end actor = Keke.find "actor_name" actor.start_action :dance while actor code looks like myself = Keke.new myself.on :dance do t = random(5) + 5 t.times do if random(50) == 0 return error "ups" end progress sleep 1 end end myself.start #################### both "Keke" (don't ask) can act as servers or clients. tell me what you think, what would you like, and if there's any point in making implementation in ruby/native threads