Skip to content

Commit

Permalink
Fix up a variety of Ruby warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rkday committed Dec 8, 2014
1 parent d094e15 commit c192d07
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions lib/concurrent/async.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ def method_missing(method, *args, &block)
super unless @delegate.respond_to?(method)
Async::validate_argc(@delegate, method, *args)

self.define_singleton_method(method) do |*args|
Async::validate_argc(@delegate, method, *args)
self.define_singleton_method(method) do |*args2|
Async::validate_argc(@delegate, method, *args2)
ivar = Concurrent::IVar.new
value, reason = nil, nil
@serializer.post(@executor.value) do
begin
value = @delegate.send(method, *args, &block)
value = @delegate.send(method, *args2, &block)
rescue => reason
# caught
ensure
Expand Down
4 changes: 2 additions & 2 deletions lib/concurrent/atomic/atomic_fixnum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module Concurrent
class MutexAtomicFixnum

# http://stackoverflow.com/questions/535721/ruby-max-integer
MIN_VALUE = -(2**(0.size * 8 -2))
MAX_VALUE = (2**(0.size * 8 -2) -1)
MIN_VALUE = -(2**(0.size * 8 - 2))
MAX_VALUE = (2**(0.size * 8 - 2) - 1)

# @!macro [attach] atomic_fixnum_method_initialize
#
Expand Down
5 changes: 1 addition & 4 deletions lib/concurrent/executor/indirect_immediate_executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def post(*args, &task)
return false unless running?

event = Concurrent::Event.new
internal_executor.post do
@internal_executor.post do
begin
task.call(*args)
ensure
Expand All @@ -39,8 +39,5 @@ def post(*args, &task)

true
end

private
attr_reader :internal_executor
end
end
1 change: 1 addition & 0 deletions lib/concurrent/executor/ruby_thread_pool_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def initialize(queue, parent)
@parent = parent
@mutex = Mutex.new
@last_activity = Time.now.to_f
@thread = nil
end

# @!visibility private
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/executor/serialized_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SerializedExecution

Job = Struct.new(:executor, :args, :block) do
def call
block.call *args
block.call(*args)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/lazy_register.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def register(key, &block)
# @return self
# @param [Object] key
def unregister(key)
@data.update { |h| h.dup.tap { |h| h.delete(key) } }
@data.update { |h| h.dup.tap { |j| j.delete(key) } }
self
end

Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/observable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def add_observer(*args, &block)
# as #add_observer but it can be used for chaining
# @return [Observable] self
def with_observer(*args, &block)
add_observer *args, &block
add_observer(*args, &block)
self
end

Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/promise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def then(rescuer = nil, &block)
# @return [Promise]
def on_success(&block)
raise ArgumentError.new('no block given') unless block_given?
self.then &block
self.then(&block)
end

# @return [Promise]
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/scheduled_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def initialize(intended_time, opts = {}, &block)
def execute
if compare_and_set_state(:pending, :unscheduled)
@schedule_time = TimerSet.calculate_schedule_time(@intended_time)
Concurrent::timer(@schedule_time.to_f - Time.now.to_f) { @executor.post &method(:process_task) }
Concurrent::timer(@schedule_time.to_f - Time.now.to_f) { @executor.post(&method(:process_task)) }
self
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/timer_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def schedule_next_task(interval = execution_interval)
def execute_task(completion)
return unless @running.true?
Concurrent::timer(execution_interval, completion, &method(:timeout_task))
success, value, reason = @executor.execute(self)
_success, value, reason = @executor.execute(self)
if completion.try?
self.value = value
schedule_next_task
Expand Down

0 comments on commit c192d07

Please sign in to comment.