Class: Rbgo::Actor

Inherits:
Object
  • Object
show all
Defined in:
lib/rbgo/actor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&handler) ⇒ Actor

Returns a new instance of Actor.



14
15
16
17
18
# File 'lib/rbgo/actor.rb', line 14

def initialize(&handler)
  self.handler  = handler
  self.mail_box = Queue.new
  start_msg_loop
end

Instance Attribute Details

#handlerObject

Returns the value of attribute handler.



12
13
14
# File 'lib/rbgo/actor.rb', line 12

def handler
  @handler
end

Instance Method Details

#closeObject



25
26
27
28
29
# File 'lib/rbgo/actor.rb', line 25

def close
  mail_box.close
  mail_box.clear
  nil
end

#closed?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/rbgo/actor.rb', line 31

def closed?
  mail_box.closed?
end

#send_msg(msg) ⇒ Object



20
21
22
23
# File 'lib/rbgo/actor.rb', line 20

def send_msg(msg)
  mail_box << msg
  nil
end