|
3 | 3 | require 'concurrent/atomic/atomic_fixnum'
|
4 | 4 | require 'timeout'
|
5 | 5 |
|
6 |
| -RSpec.shared_examples :executor_service do |
| 6 | +RSpec.shared_examples :executor_service do |immediate_type: false| |
7 | 7 |
|
8 | 8 | after(:each) do
|
9 | 9 | subject.shutdown
|
|
84 | 84 | end
|
85 | 85 | end
|
86 | 86 |
|
| 87 | + context '#shuttingdown?' do |
| 88 | + it 'returns false when the thread pool is running' do |
| 89 | + expect(subject).not_to be_shuttingdown |
| 90 | + end |
| 91 | + |
| 92 | + it 'returns true when the thread pool is shutting down' do |
| 93 | + skip "will never be in shuttingdown? state" if immediate_type |
| 94 | + |
| 95 | + subject.post{ sleep(0.5) } |
| 96 | + subject.shutdown |
| 97 | + expect(subject).to be_shuttingdown |
| 98 | + expect(subject.wait_for_termination(pool_termination_timeout)).to eq true |
| 99 | + end |
| 100 | + |
| 101 | + it 'returns false when the thread pool is shutdown' do |
| 102 | + subject.shutdown |
| 103 | + expect(subject.wait_for_termination(pool_termination_timeout)).to eq true |
| 104 | + expect(subject).not_to be_shuttingdown |
| 105 | + end |
| 106 | + |
| 107 | + it 'returns false when the thread pool is killed' do |
| 108 | + subject.kill |
| 109 | + expect(subject.wait_for_termination(pool_termination_timeout)).to eq true |
| 110 | + expect(subject).not_to be_shuttingdown |
| 111 | + end |
| 112 | + end |
| 113 | + |
| 114 | + context '#shutdown?' do |
| 115 | + it 'returns false when the thread pool is running' do |
| 116 | + expect(subject).not_to be_shutdown |
| 117 | + end |
| 118 | + |
| 119 | + it 'returns false when the thread pool is shutting down' do |
| 120 | + skip "will never be in shuttingdown? state" if immediate_type |
| 121 | + |
| 122 | + subject.post{ sleep(0.5) } |
| 123 | + subject.shutdown |
| 124 | + expect(subject).not_to be_shutdown |
| 125 | + expect(subject.wait_for_termination(pool_termination_timeout)).to eq true |
| 126 | + end |
| 127 | + |
| 128 | + it 'returns true when the thread pool is shutdown' do |
| 129 | + subject.shutdown |
| 130 | + expect(subject.wait_for_termination(pool_termination_timeout)).to eq true |
| 131 | + expect(subject).to be_shutdown |
| 132 | + end |
| 133 | + |
| 134 | + it 'returns false when the thread pool is killed' do |
| 135 | + subject.kill |
| 136 | + expect(subject.wait_for_termination(pool_termination_timeout)).to eq true |
| 137 | + expect(subject).to be_shutdown |
| 138 | + end |
| 139 | + end |
| 140 | + |
87 | 141 | context '#shutdown' do
|
88 | 142 |
|
89 | 143 | it 'stops accepting new tasks' do
|
|
0 commit comments