Class: Actor::Supervisor
Defined Under Namespace
Modules: Address, Assertions, Observer
Constant Summary
collapse
Class.new StandardError
Instance Attribute Summary collapse
#publish
Class Method Summary
collapse
Instance Method Summary
collapse
#handle_stop, #run_loop
included
included
Constructor Details
Returns a new instance of Supervisor.
16
17
18
|
# File 'lib/actor/supervisor.rb', line 16
def initialize
@actor_count = 0
end
|
Instance Attribute Details
#actor_count ⇒ Object
Returns the value of attribute actor_count.
11
12
13
|
# File 'lib/actor/supervisor.rb', line 11
def actor_count
@actor_count
end
|
#assembly_block ⇒ Object
109
110
111
|
# File 'lib/actor/supervisor.rb', line 109
def assembly_block
@assembly_block ||= proc { }
end
|
#error ⇒ Object
Returns the value of attribute error.
13
14
15
|
# File 'lib/actor/supervisor.rb', line 13
def error
@error
end
|
#thread_group ⇒ Object
113
114
115
|
# File 'lib/actor/supervisor.rb', line 113
def thread_group
@thread_group ||= ThreadGroup::Default
end
|
Class Method Details
.build(&assembly_block) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/actor/supervisor.rb', line 20
def self.build &assembly_block
instance = new
instance.assembly_block = assembly_block
instance.configure
instance
end
|
.start(&assembly_block) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/actor/supervisor.rb', line 27
def self.start &assembly_block
thread = Thread.new do
thread_group = Thread.current.group
instance = build &assembly_block
instance.run_loop
end
loop do
ten_seconds = 10
result = thread.join ten_seconds
break unless result.nil?
end
end
|
Instance Method Details
44
45
46
47
48
49
50
51
52
|
# File 'lib/actor/supervisor.rb', line 44
def configure
self.thread_group = Thread.current.group
Address::Put.(address)
assembly_block.(self)
self.publish = Messaging::Publish.build
end
|
#handle(message) ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'lib/actor/supervisor.rb', line 54
def handle message
result = super
changed
notify_observers message
result
end
|