Skip to content

Commit 399d276

Browse files
committed
Deal with bad executor early
1 parent 41cf14d commit 399d276

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/concurrent/actor.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,14 @@ def self.root
6565
# @param args see {.to_spawn_options}
6666
# @return [Reference] never the actual actor
6767
def self.spawn(*args, &block)
68+
options = to_spawn_options(*args)
69+
if options[:executor] && options[:executor].is_a?(ImmediateExecutor)
70+
raise ArgumentError, 'ImmediateExecutor is not supported'
71+
end
6872
if Actor.current
69-
Core.new(to_spawn_options(*args).merge(parent: Actor.current), &block).reference
73+
Core.new(options.merge(parent: Actor.current), &block).reference
7074
else
71-
root.ask([:spawn, to_spawn_options(*args), block]).value!
75+
root.ask([:spawn, options, block]).value!
7276
end
7377
end
7478

lib/concurrent/actor/core.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ def ns_initialize(opts, &block)
172172
allocate_context
173173

174174
@executor = Type! opts.fetch(:executor, @context.default_executor), Concurrent::AbstractExecutorService
175-
raise ArgumentError, 'ImmediateExecutor is not supported' if @executor.is_a? ImmediateExecutor
176175

177176
@reference = (Child! opts[:reference_class] || @context.default_reference_class, Reference).new self
178177
@name = (Type! opts.fetch(:name), String, Symbol).to_s

0 commit comments

Comments
 (0)