aboutsummaryrefslogtreecommitdiff
path: root/tests/workers.scm
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2017-11-19 15:01:00 +0100
committerMarius Bakke <mbakke@fastmail.com>2017-11-19 15:01:00 +0100
commit2dd12924cf4a30a96262b6d392fcde58c9f10d4b (patch)
tree3f74f5426ff214a02b8f6652f6516979657a7f98 /tests/workers.scm
parent259b4f34ba2eaefeafdb7c9f9eb56ee77f16010c (diff)
parenta93447b89a5b132221072e729d13a3f17391b8c2 (diff)
downloadpatches-2dd12924cf4a30a96262b6d392fcde58c9f10d4b.tar
patches-2dd12924cf4a30a96262b6d392fcde58c9f10d4b.tar.gz
Merge branch 'master' into core-updates
Diffstat (limited to 'tests/workers.scm')
-rw-r--r--tests/workers.scm26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/workers.scm b/tests/workers.scm
index 44b882f691..4eaefbb43d 100644
--- a/tests/workers.scm
+++ b/tests/workers.scm
@@ -42,4 +42,30 @@
(poll)))
result))
+;; Same as above, but throw exceptions within the workers and make sure they
+;; remain alive.
+(test-equal "exceptions"
+ 4242
+ (let* ((pool (make-pool 10))
+ (result 0)
+ (1+! (let ((lock (make-mutex)))
+ (lambda ()
+ (with-mutex lock
+ (set! result (+ result 1)))))))
+ (let loop ((i 10))
+ (unless (zero? i)
+ (pool-enqueue! pool (lambda ()
+ (throw 'whatever)))
+ (loop (- i 1))))
+ (let loop ((i 4242))
+ (unless (zero? i)
+ (pool-enqueue! pool 1+!)
+ (loop (- i 1))))
+ (let poll ()
+ (unless (pool-idle? pool)
+ (pk 'busy result)
+ (sleep 1)
+ (poll)))
+ result))
+
(test-end)