diff options
-rw-r--r-- | src/cuirass/utils.scm | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cuirass/utils.scm b/src/cuirass/utils.scm index 6629bc1..9e9ac36 100644 --- a/src/cuirass/utils.scm +++ b/src/cuirass/utils.scm @@ -106,16 +106,17 @@ dedicated fiber." (lambda () (let loop () (match (get-message channel) - ((? procedure? proc) - (put-message channel (apply proc args)))) + (((? channel? reply) . (? procedure? proc)) + (put-message reply (apply proc args)))) (loop)))) channel)) (define (call-with-critical-section channel proc) "Call PROC in the critical section corresponding to CHANNEL. Return the result of PROC." - (put-message channel proc) - (get-message channel)) + (let ((reply (make-channel))) + (put-message channel (cons reply proc)) + (get-message reply))) (define-syntax-rule (with-critical-section channel (vars ...) exp ...) "Evaluate EXP... in the critical section corresponding to CHANNEL. |