Skip to content

Commit

Permalink
Deal with bad executor early
Browse files Browse the repository at this point in the history
  • Loading branch information
pitr-ch committed Dec 23, 2016
1 parent 41cf14d commit 399d276
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/concurrent/actor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ def self.root
# @param args see {.to_spawn_options}
# @return [Reference] never the actual actor
def self.spawn(*args, &block)
options = to_spawn_options(*args)
if options[:executor] && options[:executor].is_a?(ImmediateExecutor)
raise ArgumentError, 'ImmediateExecutor is not supported'
end
if Actor.current
Core.new(to_spawn_options(*args).merge(parent: Actor.current), &block).reference
Core.new(options.merge(parent: Actor.current), &block).reference
else
root.ask([:spawn, to_spawn_options(*args), block]).value!
root.ask([:spawn, options, block]).value!
end
end

Expand Down
1 change: 0 additions & 1 deletion lib/concurrent/actor/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ def ns_initialize(opts, &block)
allocate_context

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

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

0 comments on commit 399d276

Please sign in to comment.