Skip to content

Commit 19466d1

Browse files
committed
when spawn returns children are set
1 parent 6887f78 commit 19466d1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/concurrent/actress.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@ def initialize(parent, name, actress_class, *args, &block)
161161
@terminated = Event.new
162162
@mutex = Mutex.new
163163

164+
parent_core.add_child reference if parent_core
165+
164166
@actress_class = Child! actress_class, ActorContext
165167
schedule_execution do
166-
parent_core.add_child reference if parent_core
167168
begin
168169
@actress = actress_class.new *args, &block
169170
@actress.send :initialize_core, self

spec/concurrent/actress_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ def on_message(message)
2929
queue = Queue.new
3030
actor = Actress.spawn Ping, :ping, queue
3131

32+
# when spawn returns children are set
33+
Actress::ROOT.send(:core).children.should include(actor)
34+
3235
actor << 'a' << 1
3336
queue.pop.should eq 'a'
3437
actor.ask(2).value.should eq 2

0 commit comments

Comments
 (0)