[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 01/02: service: Avoid continuation barrier on 'find' in Guile
From: |
Ludovic Courtès |
Subject: |
[shepherd] 01/02: service: Avoid continuation barrier on 'find' in Guile 2.2. |
Date: |
Thu, 17 Nov 2022 04:14:12 -0500 (EST) |
civodul pushed a commit to branch master
in repository shepherd.
commit 64d89748c4b1ea9ec287202140c655f189c230b5
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Nov 17 10:07:05 2022 +0100
service: Avoid continuation barrier on 'find' in Guile 2.2.
* modules/shepherd/service.scm (find) <not guile-3.0>: New procedure.
---
modules/shepherd/service.scm | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 4d7a61e..fd2ef1b 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -671,6 +671,20 @@ clients."
+(cond-expand
+ (guile-3.0 #t)
+ (else
+ ;; In Guile 2.2, SRFI-1 'find' is in C and thus introduces a continuation
+ ;; barrier, which is a problem for 'launch-service'. Provide a Scheme
+ ;; implementation to address that.
+ (define (find pred lst)
+ (let loop ((lst lst))
+ (and (not (null? lst))
+ (let ((head (car lst)))
+ (if (pred head)
+ head
+ (loop (cdr lst)))))))))
+
(define (launch-service name proc args)
"Try to start (with PROC) a service providing NAME; return #f on failure.
Used by `start' and `enforce'."