File tree Expand file tree Collapse file tree 4 files changed +26
-14
lines changed
Expand file tree Collapse file tree 4 files changed +26
-14
lines changed Original file line number Diff line number Diff line change 184184```
185185
186186It can be especially important to impose timeouts when processing user-provided data.
187-
188- ##
Original file line number Diff line number Diff line change @@ -189,14 +189,19 @@ end
189189barrier = Async ::Barrier .new
190190semaphore = Async ::Semaphore .new (2 , parent: barrier)
191191
192- jobs.each do |job |
193- semaphore.async(parent: barrier) do
194- # ... process job ...
192+ begin
193+ jobs.each do |job |
194+ semaphore.async do
195+ # ... process job ...
196+ end
195197 end
196- end
197198
198- # Wait until all jobs are done:
199- barrier.wait
199+ # Wait until all jobs are done:
200+ barrier.wait
201+ ensure
202+ # Stop any remaining jobs:
203+ barrier.stop
204+ end
200205~~~
201206
202207## Stopping a Task
Original file line number Diff line number Diff line change @@ -189,14 +189,19 @@ end
189189barrier = Async ::Barrier .new
190190semaphore = Async ::Semaphore .new (2 , parent: barrier)
191191
192- jobs.each do |job |
193- semaphore.async(parent: barrier) do
194- # ... process job ...
192+ begin
193+ jobs.each do |job |
194+ semaphore.async do
195+ # ... process job ...
196+ end
195197 end
196- end
197198
198- # Wait until all jobs are done:
199- barrier.wait
199+ # Wait until all jobs are done:
200+ barrier.wait
201+ ensure
202+ # Stop any remaining jobs:
203+ barrier.stop
204+ end
200205~~~
201206
202207## Stopping a Task
Original file line number Diff line number Diff line change 11# Releases
22
3+ ## Unreleased
4+
5+ - Fix typo in documentation.
6+
37## v2.32.0
48
59 - Introduce ` Queue#waiting_count ` and ` PriorityQueue#waiting_count ` . Generally for statistics/testing purposes only.
You can’t perform that action at this time.
0 commit comments