Class: Actor::Supervisor

Inherits:
Object
  • Object
show all
Includes:
Actor
Defined in:
lib/actor/supervisor.rb

Defined Under Namespace

Classes: ActorCrashed

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Actor

included

Constructor Details

#initialize(&assembly) ⇒ Supervisor

Returns a new instance of Supervisor.



11
12
13
# File 'lib/actor/supervisor.rb', line 11

def initialize &assembly
  @assembly = assembly
end

Class Attribute Details

.addressObject

Returns the value of attribute address.



16
17
18
# File 'lib/actor/supervisor.rb', line 16

def address
  @address
end

Instance Attribute Details

#assemblyObject (readonly)

Returns the value of attribute assembly.



5
6
7
# File 'lib/actor/supervisor.rb', line 5

def assembly
  @assembly
end

#broadcast_addressObject



81
82
83
# File 'lib/actor/supervisor.rb', line 81

def broadcast_address
  @broadcast_address ||= Address::None
end

#errorObject

Returns the value of attribute error.



7
8
9
# File 'lib/actor/supervisor.rb', line 7

def error
  @error
end

#router_addressObject



85
86
87
# File 'lib/actor/supervisor.rb', line 85

def router_address
  @router_address ||= Address::None
end

#thread_groupObject



89
90
91
# File 'lib/actor/supervisor.rb', line 89

def thread_group
  @thread_group ||= Substitutes::ThreadGroup.new
end

Class Method Details

.run(&assembly) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/actor/supervisor.rb', line 18

def run &assembly
  self.address = Address.build

  instance = build address, &assembly

  thread = Start.(instance, address)
  thread.join
end

Instance Method Details

#actor_threadsObject



69
70
71
72
73
# File 'lib/actor/supervisor.rb', line 69

def actor_threads
  list = thread_group.list
  list.delete Thread.current
  list
end

#configureObject



75
76
77
78
79
# File 'lib/actor/supervisor.rb', line 75

def configure
  self.broadcast_address = Address.build
  self.router_address = Router.start
  self.thread_group = ThreadGroup.new
end