@@ -8,8 +8,7 @@ module Actress
8
8
class Core
9
9
include TypeCheck
10
10
11
- attr_reader :reference , :name , :path , :logger , :parent_core
12
- private :parent_core
11
+ attr_reader :reference , :name , :path , :executor
13
12
14
13
# @option opts [String] name
15
14
# @option opts [Reference, nil] parent of an actor spawning this one
@@ -49,8 +48,8 @@ def initialize(opts = {}, &block)
49
48
@actress = actress_class . new *args , &block
50
49
@actress . send :initialize_core , self
51
50
rescue => ex
52
- puts " #{ ex } ( #{ ex . class } ) \n #{ ex . backtrace . join ( " \n " ) } "
53
- terminate! # TODO test this
51
+ @logger . error ex
52
+ terminate!
54
53
end
55
54
end
56
55
end
@@ -109,10 +108,10 @@ def terminate!
109
108
guard!
110
109
@terminated . set
111
110
112
- parent_core . remove_child reference if parent_core
111
+ @ parent_core. remove_child reference if @ parent_core
113
112
@mailbox . each do |envelope |
114
113
reject_envelope envelope
115
- logger . debug "rejected #{ envelope . message } from #{ envelope . sender_path } "
114
+ @ logger. debug "rejected #{ envelope . message } from #{ envelope . sender_path } "
116
115
end
117
116
@mailbox . clear
118
117
# TODO terminate all children
@@ -147,15 +146,15 @@ def receive_envelope
147
146
148
147
if terminated?
149
148
reject_envelope envelope
150
- logger . fatal "this should not be happening #{ caller [ 0 ] } "
149
+ @ logger. fatal "this should not be happening #{ caller [ 0 ] } "
151
150
end
152
151
153
- logger . debug "received #{ envelope . message } from #{ envelope . sender_path } "
152
+ @ logger. debug "received #{ envelope . message } from #{ envelope . sender_path } "
154
153
155
154
result = @actress . on_envelope envelope
156
155
envelope . ivar . set result unless envelope . ivar . nil?
157
156
rescue => error
158
- logger . error error
157
+ @ logger. error error
159
158
envelope . ivar . fail error unless envelope . ivar . nil?
160
159
terminate!
161
160
ensure
@@ -171,7 +170,7 @@ def schedule_execution
171
170
Thread . current [ :__current_actress__ ] = reference
172
171
yield
173
172
rescue => e
174
- logger . fatal e
173
+ @ logger. fatal e
175
174
ensure
176
175
Thread . current [ :__current_actress__ ] = nil
177
176
end
0 commit comments