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
  self.once_for_msg_loop = Once.new
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



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

def close
  mail_box.close
  mail_box.clear
  nil
end

#closed?Boolean

Returns:

  • (Boolean)


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

def closed?
  mail_box.closed?
end

#send_msg(msg) ⇒ Object



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

def send_msg(msg)
  mail_box << msg
  start_msg_loop
  nil
end