[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shepherd] 04/05: Avoid uses of 'call/ec'.
From: |
Ludovic Courtès |
Subject: |
[shepherd] 04/05: Avoid uses of 'call/ec'. |
Date: |
Tue, 12 Jan 2016 22:28:28 +0000 |
civodul pushed a commit to branch master
in repository shepherd.
commit 54c0ae4ffa6edc3321b92430df1143213a0f65ab
Author: Ludovic Courtès <address@hidden>
Date: Tue Jan 12 23:12:14 2016 +0100
Avoid uses of 'call/ec'.
* modules/shepherd/args.scm (process-args)[find-short-option]: Use
'find' instead of 'call/ec' + 'for-each'.
* modules/shepherd/service.scm (start, launch-service): Likewise.
(depends-resolved?): Use 'every' instead of 'call/ec'.
---
modules/shepherd/args.scm | 14 ++++++--------
modules/shepherd/service.scm | 31 ++++++++-----------------------
2 files changed, 14 insertions(+), 31 deletions(-)
diff --git a/modules/shepherd/args.scm b/modules/shepherd/args.scm
index fdcc83f..4841afb 100644
--- a/modules/shepherd/args.scm
+++ b/modules/shepherd/args.scm
@@ -1,6 +1,6 @@
;; args.scm -- Command line argument handling.
-;; Copyright (C) 2013 Ludovic Court�s <address@hidden>
-;; Copyright (C) 2002, 2003 Wolfgang J�hrling <address@hidden>
+;; Copyright (C) 2013, 2016 Ludovic Courtès <address@hidden>
+;; Copyright (C) 2002, 2003 Wolfgang Jährling <address@hidden>
;;
;; This file is part of the GNU Shepherd.
;;
@@ -19,6 +19,7 @@
(define-module (shepherd args)
#:use-module (oop goops)
+ #:use-module (srfi srfi-1)
#:use-module (shepherd support)
#:use-module (shepherd config)
#:export (<option>
@@ -119,12 +120,9 @@
;; Return the option, or `#f' if none found.
(define (find-short-option char)
- (call/ec (lambda (return)
- (for-each (lambda (option)
- (and (equal? char (short option))
- (return option)))
- options)
- #f)))
+ (find (lambda (option)
+ (equal? char (short option)))
+ options))
;; Interpret ARG as non-option argument.
(define (no-option arg)
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index a318393..849f1fe 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -211,13 +211,7 @@ respawned, shows that it has been respawned more than
TIMES in SECONDS."
;; that's running, so we can go on and launch it.
(let ((problem
;; Resolve all dependencies.
- (call/ec (lambda (return)
- (for-each (lambda (symbol)
- ;; FIXME: enforce?!
- (or (start symbol)
- (return symbol)))
- (required-by obj))
- #f))))
+ (find (negate start) (required-by obj))))
(if problem
(local-output "Service ~a depends on ~a."
(canonical-name obj)
@@ -242,7 +236,7 @@ respawned, shows that it has been respawned more than TIMES
in SECONDS."
;; Status message.
(local-output (if (running? obj)
(l10n "Service ~a has been started.")
- (l10n "Service ~a could not be started."))
+ (l10n "Service ~a could not be started."))
(canonical-name obj)))))
(slot-ref obj 'running))
@@ -433,12 +427,7 @@ clients."
;; Return whether OBJ requires something that is not yet running.
(define-method (depends-resolved? (obj <service>))
- (call/ec (lambda (return)
- (for-each (lambda (dep)
- (or (lookup-running dep)
- (return #f)))
- (required-by obj))
- #t)))
+ (every lookup-running (required-by obj)))
@@ -449,15 +438,11 @@ clients."
(which (first-running possibilities)))
(if (null? possibilities)
(local-output "No service provides ~a." name)
- (or which
- ;; None running yet, start one.
- (set! which
- (call/ec (lambda (return)
- (for-each (lambda (service)
- (and (apply proc service args)
- (return service)))
- possibilities)
- #f)))))
+ (or which
+ ;; None running yet, start one.
+ (set! which (find (lambda (service)
+ (apply proc service args))
+ possibilities))))
(or which
(let ((unknown (lookup-running 'unknown)))
(if (and unknown