projects
/
8sync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build: Require and use guile-2.2.
[8sync.git]
/
8sync
/
agenda.scm
diff --git
a/8sync/agenda.scm
b/8sync/agenda.scm
index db8180b0e0dede289f147f903f4de3b9d0844f1a..e747899a93f054865a319fdd4eef55d267e29b52 100644
(file)
--- a/
8sync/agenda.scm
+++ b/
8sync/agenda.scm
@@
-1,5
+1,5
@@
;;; 8sync --- Asynchronous programming for Guile
;;; 8sync --- Asynchronous programming for Guile
-;;; Copyright (C) 2015 Christopher Allan Webber <cwebber@dustycloud.org>
+;;; Copyright (C) 2015
, 2016
Christopher Allan Webber <cwebber@dustycloud.org>
;;;
;;; This file is part of 8sync.
;;;
;;;
;;; This file is part of 8sync.
;;;
@@
-71,6
+71,8
@@
8sync 8sync-delay
8sync-run 8sync-run-at 8sync-run-delay
8sync-port 8sync-port-remove
8sync 8sync-delay
8sync-run 8sync-run-at 8sync-run-delay
8sync-port 8sync-port-remove
+ 8sync-nowait
+ 8sleep
catch-8sync
catch-8sync
@@
-138,7
+140,7
@@
Generally done automatically for the user through (make-agenda)."
(schedule (make-schedule))
(time (gettimeofday))
(catch-handler #f)
(schedule (make-schedule))
(time (gettimeofday))
(catch-handler #f)
- (pre-unwind-handler
#f
))
+ (pre-unwind-handler
print-error-and-continue
))
;; TODO: document arguments
"Make a fresh agenda."
(make-agenda-intern queue prompt
;; TODO: document arguments
"Make a fresh agenda."
(make-agenda-intern queue prompt
@@
-593,7
+595,7
@@
Possibly specify WHEN as the second argument."
;; TODO: Write (%run-immediately)
;; TODO: Write (%run-immediately)
-(define-syntax-rule (8sync-
immediate
body)
+(define-syntax-rule (8sync-
nowait
body)
"Run body asynchronously but ignore its result...
forge ahead in our current function!"
(8sync-abort-to-prompt
"Run body asynchronously but ignore its result...
forge ahead in our current function!"
(8sync-abort-to-prompt
@@
-602,7
+604,7
@@
forge ahead in our current function!"
(list (make-run-request
;; See comment in 8sync-port
(wrap (kont #f)) #f)
(list (make-run-request
;; See comment in 8sync-port
(wrap (kont #f)) #f)
- (make-run-request
body
#f))))))
+ (make-run-request
(lambda () body)
#f))))))
(define-syntax-rule (catch-8sync exp (handler-key handler) ...)
(catch '8sync-caught-error
(define-syntax-rule (catch-8sync exp (handler-key handler) ...)
(catch '8sync-caught-error
@@
-616,6
+618,11
@@
forge ahead in our current function!"
(else (raise '8sync-caught-error
orig-key orig-args orig-stacks))))))
(else (raise '8sync-caught-error
orig-key orig-args orig-stacks))))))
+;; This is sugar... and could probably be considerably
+;; simplified and optimized. But whatever.
+(define-syntax-rule (8sleep time)
+ (8sync-delay 'no-op time))
+
\f
;;; Execution of agenda, and current agenda
\f
;;; Execution of agenda, and current agenda
@@
-742,9
+749,11
@@
Also handles sleeping when all we have to do is wait on the schedule."
#:key
;; @@: Should we make stop-on-nothing-to-do
;; the default stop-condition?
#:key
;; @@: Should we make stop-on-nothing-to-do
;; the default stop-condition?
- stop-condition
+ (stop-condition stop-on-nothing-to-do)
(get-time gettimeofday)
(get-time gettimeofday)
- (handle-ports update-agenda-from-select!))
+ (handle-ports update-agenda-from-select!)
+ ;; For live hacking madness, etc
+ (post-run-hook #f))
;; TODO: Document fields
"Start up the AGENDA"
(let loop ((agenda agenda))
;; TODO: Document fields
"Start up the AGENDA"
(let loop ((agenda agenda))
@@
-753,6
+762,11
@@
Also handles sleeping when all we have to do is wait on the schedule."
;; select'ing on ports.
;; We could compose over agenda-run-once and agenda-read-ports
(agenda-run-once agenda)))
;; select'ing on ports.
;; We could compose over agenda-run-once and agenda-read-ports
(agenda-run-once agenda)))
+ ;; @@: This relies on mutation at present on the queue, in the rare
+ ;; event it's used. If we ever switch to something more immutable,
+ ;; it should return a new modified agenda instead.
+ (if post-run-hook
+ (post-run-hook agenda))
(if (and stop-condition (stop-condition agenda))
'done
(let* ((agenda
(if (and stop-condition (stop-condition agenda))
'done
(let* ((agenda