|
312 | 312 | (with-mutex mutex |
313 | 313 | (num-threads-set! pool (+ (- (num-threads-get pool) start-threads) count)) |
314 | 314 | ;; We could be down to 0 threads if all of these |
315 | | - ;; unfortunate events have occurred together: (i) in |
316 | | - ;; the period between this calling thread releasing |
317 | | - ;; the mutex acquired on entry to this procedure and |
318 | | - ;; acquiring it again on handling this exception, |
319 | | - ;; another thread tried, concurrently with this |
320 | | - ;; attempted increase, to reduce the size of the pool |
321 | | - ;; by an amount equal to or more than its original |
322 | | - ;; size, (ii) during that period a number of tasks |
323 | | - ;; equal to that original size have finished, and (iii) |
324 | | - ;; the attempt to launch new threads failed with an |
325 | | - ;; exception without launching even one of them. In |
326 | | - ;; such a case we should be able to launch a rescue |
327 | | - ;; thread because no other threads could be running in |
328 | | - ;; the pool. If we still cannot launch a thread the |
329 | | - ;; program and/or system must be totally borked anyway |
330 | | - ;; and there is little we can do. |
| 315 | + ;; unfortunate events have occurred together: |
| 316 | + ;; (i) in the period between this calling thread |
| 317 | + ;; releasing the mutex acquired on entry to this |
| 318 | + ;; procedure and acquiring it again on handling |
| 319 | + ;; this exception, another thread tried, |
| 320 | + ;; concurrently with this attempted increase, to |
| 321 | + ;; reduce the size of the pool by an amount |
| 322 | + ;; equal to or more than its original size, (ii) |
| 323 | + ;; during that period a number of tasks equal to |
| 324 | + ;; that original size have finished, and (iii) |
| 325 | + ;; the attempt to launch new threads failed with |
| 326 | + ;; an exception without launching even one of |
| 327 | + ;; them. In such a case we should be able to |
| 328 | + ;; launch a rescue thread within the mutex |
| 329 | + ;; because no other threads could be running in |
| 330 | + ;; the pool. If we still cannot launch a thread |
| 331 | + ;; the program and/or system must be totally |
| 332 | + ;; borked and there is little we can do. |
331 | 333 | (when (zero? (num-threads-get pool)) |
332 | 334 | ;; if this fails, all is lost (that is, we may have |
333 | 335 | ;; queued tasks in the pool with no thread startable |
|
0 commit comments