Skip to content

Commit

Permalink
Merge pull request #204 from rkday/fix_up_warnings
Browse files Browse the repository at this point in the history
Fix up warnings
  • Loading branch information
jdantonio committed Dec 9, 2014
2 parents a66d78c + c192d07 commit 67d6631
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion doc/thread_pools.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A Thread Pool is an abstraction that you can give a unit of work to, and the wor

But there are some problems for which directly using a thread pool is an appropriate solution. Or, you may wish to make your own thread pool to run Futures on, to be separate or have different characteristics than the global thread pool that Futures run on by default.

Thread pools are considered 'executors' -- an object you can give a unit of work to, to have it execucted. In fact, thread pools are the main kind of executor you will see - others are mainly for testing or odd edge cases. In some documentation or source code you'll see reference to an 'executor' -- this is commonly a thread pool, or else something similar that executes units of work (usually supplied as Ruby blocks).
Thread pools are considered 'executors' -- an object you can give a unit of work to, to have it executed. In fact, thread pools are the main kind of executor you will see - others are mainly for testing or odd edge cases. In some documentation or source code you'll see reference to an 'executor' -- this is commonly a thread pool, or else something similar that executes units of work (usually supplied as Ruby blocks).

## FixedThreadPool

Expand Down
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 67d6631

Please sign in to comment.