Skip to content

Commit

Permalink
Do not reset global threads
Browse files Browse the repository at this point in the history
  • Loading branch information
pitr-ch committed Mar 2, 2018
1 parent d294f98 commit 8686aac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
20 changes: 3 additions & 17 deletions spec/concurrent/executor/timer_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,14 @@ module Concurrent
after(:each){ subject.kill }

context 'construction' do

before(:all) do
reset_gem_configuration
end

after(:each) do
reset_gem_configuration
end

it 'uses the executor given at construction' do
executor = Concurrent.global_immediate_executor
expect(executor).to receive(:post).with(no_args)
subject = TimerSet.new(executor: executor)
subject.post(0){ nil }
subject = TimerSet.new(executor: Concurrent.global_immediate_executor)
expect(subject.instance_variable_get(:@task_executor)).to eq Concurrent.global_immediate_executor
end

it 'uses the global io executor be default' do
latch = Concurrent::CountDownLatch.new(1)
expect(Concurrent.global_io_executor).to receive(:post).with(no_args)
subject = TimerSet.new
subject.post(0){ latch.count_down }
latch.wait(0.1)
expect(subject.instance_variable_get(:@task_executor)).to eq Concurrent.global_io_executor
end
end

Expand Down
16 changes: 0 additions & 16 deletions spec/support/example_group_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,6 @@ def use_c_extensions?
Concurrent.allow_c_extensions?
end

GLOBAL_EXECUTORS = [
[:GLOBAL_FAST_EXECUTOR, -> { Delay.new { Concurrent.new_fast_executor(auto_terminate: true) } }],
[:GLOBAL_IO_EXECUTOR, -> { Delay.new { Concurrent.new_io_executor(auto_terminate: true) } }],
[:GLOBAL_TIMER_SET, -> { Delay.new { Concurrent::TimerSet.new(auto_terminate: true) } }],
]

def reset_gem_configuration
GLOBAL_EXECUTORS.each do |var, factory|
executor = Concurrent.const_get(var).value!
executor.shutdown
executor.wait_for_termination(0.2)
executor.kill
Concurrent.const_set(var, factory.call)
end
end

def monotonic_interval
raise ArgumentError.new('no block given') unless block_given?
start_time = GLOBAL_MONOTONIC_CLOCK.get_time
Expand Down

0 comments on commit 8686aac

Please sign in to comment.