Skip to content

Commit

Permalink
Renamed global_timer_pool to global_timer_set to be more consistent.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdantonio committed Apr 12, 2014
1 parent e91b3b1 commit fd397db
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/concurrent/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.configure
# initialize the global thread pools if necessary
configuration.global_task_pool
configuration.global_operation_pool
configuration.global_timer_pool
configuration.global_timer_set
end
end

Expand Down Expand Up @@ -66,8 +66,8 @@ def global_operation_pool
# @return [ThreadPoolExecutor] the thread pool
#
# @see Concurrent::timer
def global_timer_pool
@global_timer_pool ||= Concurrent::TimerSet.new
def global_timer_set
@global_timer_set ||= Concurrent::TimerSet.new
end

# Global thread pool optimized for short *tasks*.
Expand Down Expand Up @@ -134,6 +134,7 @@ def self.finalize_executor(executor)

# set exit hook to shutdown global thread pools
at_exit do
self.finalize_executor(self.configuration.global_timer_set)
self.finalize_executor(self.configuration.global_task_pool)
self.finalize_executor(self.configuration.global_operation_pool)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/utility/timer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def timer(seconds, &block)
raise ArgumentError.new('no block given') unless block_given?
raise ArgumentError.new('interval must be greater than or equal to zero') if seconds < 0

Concurrent.configuration.global_timer_pool.post(seconds, &block)
Concurrent.configuration.global_timer_set.post(seconds, &block)
true
end
module_function :timer
Expand Down
4 changes: 2 additions & 2 deletions spec/concurrent/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Concurrent
describe Configuration do

it 'creates a global timer pool' do
Concurrent.configuration.global_timer_pool.should_not be_nil
Concurrent.configuration.global_timer_pool.should respond_to(:post)
Concurrent.configuration.global_timer_set.should_not be_nil
Concurrent.configuration.global_timer_set.should respond_to(:post)
end

context 'global task pool' do
Expand Down
2 changes: 1 addition & 1 deletion spec/concurrent/utility/timer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module Concurrent
end

it 'runs the task on the global timer pool' do
Concurrent.configuration.global_timer_pool.should_receive(:post).with(0.1)
Concurrent.configuration.global_timer_set.should_receive(:post).with(0.1)
Concurrent::timer(0.1){ :foo }
end
end
Expand Down

0 comments on commit fd397db

Please sign in to comment.