agenda: Add yield procedure.
[8sync.git] / 8sync / agenda.scm
index ae9ddd6059556fc781d69bae7bcc3cd902db6681..b14f7b1204b2752ba9609d0837bb0444e8f87ea8 100644 (file)
@@ -62,7 +62,7 @@
 
             8sync-delay
             8sync-run 8sync-run-at 8sync-run-delay
-            8sync-nowait
+            8sync
             8sleep
             
             ;; used for introspecting the error, but a method for making
@@ -527,7 +527,7 @@ return the wrong thing via (8sync) and trip themselves up."
 
 ;; TODO: Write (%run-immediately)
 
-(define-syntax-rule (8sync-nowait body)
+(define-syntax-rule (8sync body)
   "Run body asynchronously but ignore its result...
 forge ahead in our current function!"
   (8sync-abort-to-prompt
@@ -545,6 +545,13 @@ forge ahead in our current function!"
 (define-syntax-rule (8sleep time)
   (8sync-delay 'no-op time))
 
+;; Voluntarily yield execution
+(define (yield)  ; @@: should this be define-inlinable?
+  "Voluntarily yield execution to the scheduler."
+  (8sync-abort-to-prompt
+   (make-async-request
+    (lambda (kont)
+      (make-run-request (lambda () (kont #f)) #f)))))
 
 \f
 ;;; Execution of agenda, and current agenda