93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/actor/actor.rb', line 93
def spawn *positional_arguments, include: nil, **keyword_arguments, &block
address = Messaging::Address.build
method = if respond_to? :build then :build else :new end
if keyword_arguments.empty?
instance = __send__ method, *positional_arguments, &block
else
instance = __send__ method, *positional_arguments, **keyword_arguments, &block
end
reader = Messaging::Reader.build address
instance.actor_address = address
instance.actor_state = State::Paused
instance.reader = reader
thread = ::Thread.new do
instance.run_loop
end
destructure instance, address, thread, include: include
end
|