port-request-port
port-request-read port-request-write port-request-except
- run-it wrap run run-at run-delay
+ run-it wrap wrap-apply run run-at run-delay
%port-request %run %run-at %run-delay
8port-request 8run 8run-at 8run-delay
"Subtract TIME2 from TIME1"
(time-carry-correct
(cons (- (car time1) (car time2))
- (- (cdr time2) (cdr time2)))))
+ (- (cdr time1) (cdr time2)))))
(define (time-plus time1 time2)
"Add TIME1 and TIME2"
(time-carry-correct
(cons (+ (car time1) (car time2))
- (+ (cdr time2) (cdr time2)))))
+ (+ (cdr time1) (cdr time2)))))
(define-record-type <schedule>
(lambda ()
body ...))
+(define-syntax-rule (wrap-apply body)
+ "Wrap possibly multi-value function in a procedure, applies all arguments"
+ (lambda args
+ (apply body args)))
+
+
;; @@: Do we really want `body ...' here?
;; what about just `body'?
(define-syntax-rule (run body ...)
;; TODO: support usecond wait time too
(match (get-wait-time)
((sec . usec)
- (select (hash-keys (agenda-read-port-map agenda))
- (hash-keys (agenda-write-port-map agenda))
- (hash-keys (agenda-except-port-map agenda))
- sec usec))))
+ (catch 'system-error
+ (lambda ()
+ (select (hash-keys (agenda-read-port-map agenda))
+ (hash-keys (agenda-write-port-map agenda))
+ (hash-keys (agenda-except-port-map agenda))
+ sec usec))
+ (lambda (key . rest-args)
+ (match rest-args
+ ((_ _ _ (EINTR))
+ '(() () ()))
+ (_ (error "Unhandled error in select!" key rest-args))))))))
(define (get-procs-to-run)
(define (ports->procs ports port-map)
(lambda (initial-procs)