Skip to content

Commit f104631

Browse files
committed
Merge pull request #202 from ruby-concurrency/refactor/changelog-and-warnings
Warnings when using deprecated :overflow_policy thread pool option
2 parents 0d43d21 + 521ef52 commit f104631

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### Next Release v0.7.2 (TBD)
2+
3+
* Renamed `:overflow_policy` on thread pools to `:fallback_policy`
4+
* Thread pools still accept the `:overflow_policy` option but display a warning
5+
* Thread pools now implement `fallback_policy` behavior when not running (rather than universally rejecting tasks)
6+
* Test now run on new Travis build environment
7+
18
## Current Release v0.7.1 (4 December 2014)
29

310
Please see the [roadmap](https://github.com/ruby-concurrency/concurrent-ruby/issues/142) for more information on the next planned release.

lib/concurrent/configuration.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def new_task_pool
102102
max_threads: [20, Concurrent.processor_count * 15].max,
103103
idletime: 2 * 60, # 2 minutes
104104
max_queue: 0, # unlimited
105-
overflow_policy: :abort # raise an exception
105+
fallback_policy: :abort # raise an exception
106106
)
107107
end
108108

@@ -112,7 +112,7 @@ def new_operation_pool
112112
max_threads: [2, Concurrent.processor_count].max,
113113
idletime: 10 * 60, # 10 minutes
114114
max_queue: [20, Concurrent.processor_count * 15].max,
115-
overflow_policy: :abort # raise an exception
115+
fallback_policy: :abort # raise an exception
116116
)
117117
end
118118
end

lib/concurrent/executor/java_cached_thread_pool.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class JavaCachedThreadPool < JavaThreadPoolExecutor
1717
# @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool--
1818
def initialize(opts = {})
1919
@fallback_policy = opts.fetch(:fallback_policy, opts.fetch(:overflow_policy, :abort))
20+
warn '[DEPRECATED] :overflow_policy is deprecated terminology, please use :fallback_policy instead' if opts.has_key?(:overflow_policy)
2021
@max_queue = 0
2122

2223
raise ArgumentError.new("#{@fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICIES.keys.include?(@fallback_policy)

lib/concurrent/executor/java_fixed_thread_pool.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ def initialize(num_threads, opts = {})
2424
}.merge(opts)
2525
super(opts)
2626

27-
28-
#@fallback_policy = opts.fetch(:fallback_policy, :abort)
29-
#@max_queue = 0
30-
#
31-
#raise ArgumentError.new('number of threads must be greater than zero') if num_threads < 1
32-
#raise ArgumentError.new("#{@fallback_policy} is not a valid fallback policy") unless FALLBACK_POLICIES.keys.include?(@fallback_policy)
33-
#
34-
#@executor = java.util.concurrent.Executors.newFixedThreadPool(num_threads)
35-
#@executor.setRejectedExecutionHandler(FALLBACK_POLICIES[@FALLBACK_policy].new)
36-
3727
set_shutdown_hook
3828
end
3929
end

lib/concurrent/executor/java_thread_pool_executor.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def initialize(opts = {})
5757
idletime = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i
5858
@max_queue = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i
5959
@fallback_policy = opts.fetch(:fallback_policy, opts.fetch(:overflow_policy, :abort))
60+
warn '[DEPRECATED] :overflow_policy is deprecated terminology, please use :fallback_policy instead' if opts.has_key?(:overflow_policy)
6061

6162
raise ArgumentError.new('max_threads must be greater than zero') if max_length <= 0
6263
raise ArgumentError.new('min_threads cannot be less than zero') if min_length < 0

lib/concurrent/executor/ruby_thread_pool_executor.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def initialize(opts = {})
7575
@idletime = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i
7676
@max_queue = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i
7777
@fallback_policy = opts.fetch(:fallback_policy, opts.fetch(:overflow_policy, :abort))
78+
warn '[DEPRECATED] :overflow_policy is deprecated terminology, please use :fallback_policy instead' if opts.has_key?(:overflow_policy)
7879

7980
raise ArgumentError.new('max_threads must be greater than zero') if @max_length <= 0
8081
raise ArgumentError.new('min_threads cannot be less than zero') if @min_length < 0

spec/concurrent/executor/thread_pool_executor_shared.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,16 @@
342342
end
343343
end
344344

345-
context '#overflow_policy' do
346-
context ':caller_runs is honoured even if the old overflow_policy arg is used' do
345+
context '#fallback_policy' do
346+
context ':caller_runs is honoured even if the old fallback_policy arg is used' do
347347

348348
subject do
349349
described_class.new(
350350
min_threads: 1,
351351
max_threads: 1,
352352
idletime: 60,
353353
max_queue: 1,
354-
overflow_policy: :caller_runs
354+
fallback_policy: :caller_runs
355355
)
356356
end
357357

0 commit comments

Comments
 (0)