;;; 8sync --- Asynchronous programming for Guile
-;;; Copyright (C) 2015, 2016 Christopher Allan Webber <cwebber@dustycloud.org>
+;;; Copyright © 2015, 2016, 2017 Christopher Allan Webber <cwebber@dustycloud.org>
;;;
;;; This file is part of 8sync.
;;;
;; convert into sec / usec pair
(receive (secs usecs)
(floor/ next-time-in-usecs 1000000)
- (cons secs (floor usecs))))
+ (cons (inexact->exact secs)
+ (inexact->exact (floor usecs)))))
(define (convert-integer)
(cons (+ in-secs cur-secs) cur-usecs))
(if (integer? in-secs)
;; TODO: support usecond wait time too
(match (get-wait-time)
((sec . usec)
- (catch 'system-error
+ (catch #t ; expect: wrong-type-arg (open port), system-error
(lambda ()
(select (hash-keys (agenda-read-port-map agenda))
(hash-keys (agenda-write-port-map agenda))
'()
sec usec))
(lambda (key . rest-args)
+ (unless (and (memq key '(system-error wrong-type-arg))
+ (match rest-args
+ (((or "select" "get-u8" "get-bytevector-n" "lookahead-u8"
+ "put-u8" "put-bytevector") arg ...) #t)
+ (_ #f)))
+ (apply throw key rest-args))
(match rest-args
((_ _ _ (EINTR))
'(() () ()))
"Start up the AGENDA"
(install-suspendable-ports!)
(parameterize ((%current-agenda-prompt (agenda-prompt-tag agenda))
- ;; @@: Couldn't we just parameterize this at the start of
- ;; the agenda...?
(current-read-waiter wait-for-readable)
(current-write-waiter wait-for-writable))
(while (not (stop-condition agenda))