Skip to content

Commit 08835fe

Browse files
committed
Add AbstractContext#default_executor
to be able to override executor class wide
1 parent 810a591 commit 08835fe

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/concurrent/actor/context.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ def default_reference_class
7777
Reference
7878
end
7979

80+
# override to se different default executor, e.g. to change it to global_operation_pool
81+
# @return [Executor]
82+
def default_executor
83+
Concurrent.configuration.global_task_pool
84+
end
85+
8086
# tell self a message
8187
def tell(message)
8288
reference.tell message

lib/concurrent/actor/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def initialize(opts = {}, &block)
5555
@context_class = Child! opts.fetch(:class), AbstractContext
5656
allocate_context
5757

58-
@executor = Type! opts.fetch(:executor, Concurrent.configuration.global_task_pool), Executor
58+
@executor = Type! opts.fetch(:executor, @context.default_executor), Executor
5959
raise ArgumentError, 'ImmediateExecutor is not supported' if @executor.is_a? ImmediateExecutor
6060

6161
@reference = (Child! opts[:reference_class] || @context.default_reference_class, Reference).new self

0 commit comments

Comments
 (0)