Skip to content

Commit b81c15f

Browse files
committed
Cleared all interpreter warnings except circular references.
* Added parenthesis when using splat operator * Used _ for unused variables * Renamed variables when block echoed surrounding scope * Configuration now autoloads lazily. * Cleared all circular references.
1 parent 8dfeed0 commit b81c15f

File tree

10 files changed

+40
-39
lines changed

10 files changed

+40
-39
lines changed

lib/concurrent/actor/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def ns_initialize(opts, &block)
208208
end
209209

210210
def initialize_behaviours(opts)
211-
@behaviour_definition = (Type! opts[:behaviour_definition] || @context.behaviour_definition, Array).each do |(behaviour, *args)|
211+
@behaviour_definition = (Type! opts[:behaviour_definition] || @context.behaviour_definition, Array).each do |(behaviour, _)|
212212
Child! behaviour, Behaviour::Abstract
213213
end
214214
@behaviours = {}

lib/concurrent/actor/utils/pool.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def initialize(size, &worker_initializer)
3737
end
3838

3939
def on_message(message)
40-
command, *rest = message
40+
command, _ = message
4141
return if [:restarted, :reset, :resumed, :terminated].include? command # ignore events from supervised actors
4242

4343
envelope_to_redirect = if envelope.future

lib/concurrent/collection/copy_on_notify_observer_set.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def duplicate_and_clear_observers
100100
end
101101

102102
def duplicate_observers
103-
synchronize { observers = @observers.dup }
103+
synchronize { @observers.dup }
104104
end
105105

106106
def notify_to(observers, *args)

lib/concurrent/configuration.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
require 'thread'
2-
require 'concurrent/atomics'
2+
require 'concurrent/delay'
33
require 'concurrent/errors'
4-
require 'concurrent/executors'
4+
require 'concurrent/atomic/atomic_reference'
55
require 'concurrent/concern/deprecation'
66
require 'concurrent/concern/logging'
7+
require 'concurrent/executor/timer_set'
8+
require 'concurrent/executor/immediate_executor'
9+
require 'concurrent/executor/fixed_thread_pool'
10+
require 'concurrent/executor/thread_pool_executor'
711
require 'concurrent/utility/at_exit'
812
require 'concurrent/utility/processor_counter'
913

@@ -32,8 +36,8 @@ def self.create_stdlib_logger(level = Logger::FATAL, output = $stderr)
3236
formatted_message
3337
end
3438

35-
lambda do |level, progname, message = nil, &block|
36-
logger.add level, message, progname, &block
39+
lambda do |loglevel, progname, message = nil, &block|
40+
logger.add loglevel, message, progname, &block
3741
end
3842
end
3943

lib/concurrent/delay.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'thread'
2-
require 'concurrent/configuration'
32
require 'concurrent/concern/obligation'
43
require 'concurrent/executor/executor'
54
require 'concurrent/executor/immediate_executor'

lib/concurrent/edge/future.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def post(*args, &job)
113113
# post job on executor
114114
# @return [true, false]
115115
def post_on(executor, *args, &job)
116-
Concurrent.executor(executor).post *args, &job
116+
Concurrent.executor(executor).post(*args, &job)
117117
end
118118

119119
# TODO add first(futures, count=count)
@@ -307,7 +307,7 @@ def set(*args, &block)
307307
# @!visibility private
308308
def complete_with(state, raise_on_reassign = true)
309309
if @State.compare_and_set(PENDING, state)
310-
(state)
310+
#(state)
311311
# go to synchronized block only if there were waiting threads
312312
synchronize { ns_broadcast } if @Waiters.clear
313313
call_callbacks
@@ -323,7 +323,7 @@ def complete_with(state, raise_on_reassign = true)
323323
# @return [Array<AbstractPromise>]
324324
def blocks
325325
@Callbacks.each_with_object([]) do |callback, promises|
326-
promises.push *callback.select { |v| v.is_a? AbstractPromise }
326+
promises.push(*(callback.select { |v| v.is_a? AbstractPromise }))
327327
end
328328
end
329329

@@ -464,7 +464,7 @@ def to_sym
464464
# @!visibility private
465465
class SuccessArray < Success
466466
def apply(block)
467-
block.call *value
467+
block.call(*value)
468468
end
469469
end
470470

@@ -520,7 +520,7 @@ def reason
520520
end
521521

522522
def apply(block)
523-
block.call *reason
523+
block.call(*reason)
524524
end
525525
end
526526

@@ -776,14 +776,14 @@ def call_callback(method, state, *args)
776776
end
777777

778778
def pr_async_callback_on_success(state, executor, callback)
779-
pr_with_async(executor, state, callback) do |state, callback|
780-
pr_callback_on_success state, callback
779+
pr_with_async(executor, state, callback) do |st, cb|
780+
pr_callback_on_success st, cb
781781
end
782782
end
783783

784784
def pr_async_callback_on_failure(state, executor, callback)
785-
pr_with_async(executor, state, callback) do |state, callback|
786-
pr_callback_on_failure state, callback
785+
pr_with_async(executor, state, callback) do |st, cb|
786+
pr_callback_on_failure st, cb
787787
end
788788
end
789789

@@ -804,8 +804,8 @@ def pr_callback_notify_blocked(state, promise)
804804
end
805805

806806
def pr_async_callback_on_completion(state, executor, callback)
807-
pr_with_async(executor, state, callback) do |state, callback|
808-
pr_callback_on_completion state, callback
807+
pr_with_async(executor, state, callback) do |st, cb|
808+
pr_callback_on_completion st, cb
809809
end
810810
end
811811

@@ -981,7 +981,7 @@ def initialize(future, blocked_by_futures, countdown)
981981
@Countdown = AtomicFixnum.new countdown
982982

983983
super(future)
984-
@BlockedBy.each { |future| future.add_callback :pr_callback_notify_blocked, self }
984+
@BlockedBy.each { |f| f.add_callback :pr_callback_notify_blocked, self }
985985
end
986986

987987
# @api private
@@ -1063,8 +1063,8 @@ def initialize(blocked_by_future, default_executor, executor, &task)
10631063

10641064
def on_completable(done_future)
10651065
if done_future.success?
1066-
Concurrent.post_on(@Executor, done_future, @Task) do |done_future, task|
1067-
evaluate_to lambda { done_future.apply task }
1066+
Concurrent.post_on(@Executor, done_future, @Task) do |future, task|
1067+
evaluate_to lambda { future.apply task }
10681068
end
10691069
else
10701070
complete_with done_future.internal_state
@@ -1082,8 +1082,8 @@ def initialize(blocked_by_future, default_executor, executor, &task)
10821082

10831083
def on_completable(done_future)
10841084
if done_future.failed?
1085-
Concurrent.post_on(@Executor, done_future, @Task) do |done_future, task|
1086-
evaluate_to lambda { done_future.apply task }
1085+
Concurrent.post_on(@Executor, done_future, @Task) do |future, task|
1086+
evaluate_to lambda { future.apply task }
10871087
end
10881088
else
10891089
complete_with done_future.internal_state
@@ -1097,7 +1097,7 @@ class ChainPromise < BlockedTaskPromise
10971097

10981098
def on_completable(done_future)
10991099
if Future === done_future
1100-
Concurrent.post_on(@Executor, done_future, @Task) { |future, task| evaluate_to *future.result, task }
1100+
Concurrent.post_on(@Executor, done_future, @Task) { |future, task| evaluate_to(*future.result, task) }
11011101
else
11021102
Concurrent.post_on(@Executor, @Task) { |task| evaluate_to task }
11031103
end

lib/concurrent/executor/executor.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
require 'concurrent/executor/executor_service'
1+
require 'concurrent/configuration'
22
require 'concurrent/concern/deprecation'
3+
require 'concurrent/executor/executor_service'
34

45
module Concurrent
56

lib/concurrent/executor/ruby_thread_pool_executor.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def ns_shutdown_execution
166166
def ns_kill_execution
167167
# TODO log out unprocessed tasks in queue
168168
# TODO try to shutdown first?
169-
@pool.each &:kill
169+
@pool.each(&:kill)
170170
@pool.clear
171171
@ready.clear
172172
end
@@ -297,32 +297,31 @@ def kill
297297
private
298298

299299
def create_worker(queue, pool, idletime)
300-
Thread.new(queue, pool, idletime) do |queue, pool, idletime|
300+
Thread.new(queue, pool, idletime) do |my_queue, my_pool, my_idletime|
301301
last_message = Concurrent.monotonic_time
302302
catch(:stop) do
303303
loop do
304304

305-
case message = queue.pop
305+
case message = my_queue.pop
306306
when :idle_test
307-
if (Concurrent.monotonic_time - last_message) > idletime
308-
pool.remove_busy_worker(self)
307+
if (Concurrent.monotonic_time - last_message) > my_idletime
308+
my_pool.remove_busy_worker(self)
309309
throw :stop
310310
else
311-
pool.worker_not_old_enough(self)
311+
my_pool.worker_not_old_enough(self)
312312
end
313313

314314
when :stop
315-
pool.remove_busy_worker(self)
315+
my_pool.remove_busy_worker(self)
316316
throw :stop
317317

318318
else
319319
task, args = message
320-
run_task pool, task, args
320+
run_task my_pool, task, args
321321
last_message = Concurrent.monotonic_time
322322

323-
pool.ready_worker(self)
323+
my_pool.ready_worker(self)
324324
end
325-
326325
end
327326
end
328327
end

lib/concurrent/scheduled_task.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
require 'concurrent/errors'
22
require 'concurrent/ivar'
3-
require 'concurrent/configuration'
43
require 'concurrent/collection/copy_on_notify_observer_set'
54
require 'concurrent/executor/executor'
6-
require 'concurrent/executor/timer_set'
75
require 'concurrent/utility/monotonic_time'
86
require 'concurrent/concern/deprecation'
97

lib/concurrent/utility/at_exit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class AtExitImplementation < Synchronization::Object
1212

1313
def initialize(*args)
1414
super()
15-
synchronize { ns_initialize *args }
15+
synchronize { ns_initialize(*args) }
1616
end
1717

1818
# Add a handler to be run at `Kernel#at_exit`

0 commit comments

Comments
 (0)