|
16 | 16 | latch = Concurrent::CountDownLatch.new(1) |
17 | 17 | subject.post{ sleep(1) } |
18 | 18 | subject.shutdown |
19 | | - subject.post{ latch.count_down } |
| 19 | + begin |
| 20 | + subject.post{ latch.count_down } |
| 21 | + rescue Concurrent::RejectedExecutionError |
| 22 | + end |
20 | 23 | expect(latch.wait(0.1)).to be_falsey |
21 | 24 | end |
22 | 25 |
|
23 | | - it 'returns false while shutting down' do |
24 | | - subject.post{ sleep(1) } |
25 | | - subject.shutdown |
26 | | - expect(subject.post{ nil }).to be_falsey |
27 | | - end |
28 | | - |
29 | 26 | it 'rejects the block once shutdown' do |
30 | 27 | subject.shutdown |
31 | 28 | latch = Concurrent::CountDownLatch.new(1) |
32 | | - subject.post{ sleep(1) } |
33 | | - subject.post{ latch.count_down } |
| 29 | + begin |
| 30 | + subject.post{ latch.count_down } |
| 31 | + rescue Concurrent::RejectedExecutionError |
| 32 | + end |
34 | 33 | expect(latch.wait(0.1)).to be_falsey |
35 | 34 | end |
36 | | - |
37 | | - it 'returns false once shutdown' do |
38 | | - subject.post{ nil } |
39 | | - subject.shutdown |
40 | | - sleep(0.1) |
41 | | - expect(subject.post{ nil }).to be_falsey |
42 | | - end |
43 | 35 | end |
44 | 36 |
|
45 | 37 | context '#running?' do |
|
75 | 67 | latch2 = Concurrent::CountDownLatch.new(1) |
76 | 68 | subject.post{ sleep(0.2); latch1.count_down } |
77 | 69 | subject.shutdown |
78 | | - expect(subject.post{ latch2.count_down }).to be_falsey |
| 70 | + begin |
| 71 | + expect(subject.post{ latch2.count_down }).to be_falsey |
| 72 | + rescue Concurrent::RejectedExecutionError |
| 73 | + end |
79 | 74 | expect(latch1.wait(1)).to be_truthy |
80 | 75 | expect(latch2.wait(0.2)).to be_falsey |
81 | 76 | end |
|
121 | 116 | subject.post{ sleep(0.1); expected.increment } |
122 | 117 | subject.post{ sleep(0.1); expected.increment } |
123 | 118 | subject.shutdown |
124 | | - subject.post{ expected.increment } |
| 119 | + begin |
| 120 | + subject.post{ expected.increment } |
| 121 | + rescue Concurrent::RejectedExecutionError |
| 122 | + end |
125 | 123 | subject.wait_for_termination(1) |
126 | 124 | expect(expected.value).to eq(2) |
127 | 125 | end |
|
135 | 133 | subject.post{ sleep(0.1); latch.count_down } |
136 | 134 | latch.wait(1) |
137 | 135 | subject.kill |
138 | | - expect(subject.post{ expected.make_true }).to be_falsey |
| 136 | + begin |
| 137 | + expect(subject.post{ expected.make_true }).to be_falsey |
| 138 | + rescue Concurrent::RejectedExecutionError |
| 139 | + end |
139 | 140 | sleep(0.1) |
140 | 141 | expect(expected.value).to be_falsey |
141 | 142 | end |
|
145 | 146 | sleep(0.1) |
146 | 147 | subject.kill |
147 | 148 | sleep(0.1) |
148 | | - expect(subject.post{ nil }).to be_falsey |
| 149 | + begin |
| 150 | + expect(subject.post{ nil }).to be_falsey |
| 151 | + rescue Concurrent::RejectedExecutionError |
| 152 | + end |
149 | 153 | end |
150 | 154 | end |
151 | 155 |
|
|
0 commit comments