X-Git-Url: https://jxself.org/git/?p=8sync.git;a=blobdiff_plain;f=8sync%2Fagenda.scm;h=b41500dec5f502ce6a2d6188f3a2ceb4b056bbe7;hp=da578a77f25a0ad839ba80f379ded4bac102d697;hb=5dc2dceda9fab1eb92295989e8e8940fbd56a12c;hpb=9adac66bf1a1cf8e363aef54ddc7c14120c8f0c6 diff --git a/8sync/agenda.scm b/8sync/agenda.scm index da578a7..b41500d 100644 --- a/8sync/agenda.scm +++ b/8sync/agenda.scm @@ -60,10 +60,8 @@ run-it wrap wrap-apply run run-at run-delay - 8sync-delay - 8sync-run 8sync-run-at 8sync-run-delay 8sync - 8sleep + 8sleep 8usleep ;; used for introspecting the error, but a method for making ;; is not exposed @@ -471,11 +469,25 @@ forge ahead in our current function!" (make-run-request (lambda () body ...) #f)))))) ;; TODO: Rewrite when we move to this being just `sleep'. -(define (8sleep time) +(define (8sleep secs) + "Like sleep, but asynchronous." (8sync-abort-to-prompt (make-async-request (lambda (kont) - (make-run-request (lambda () (kont #f)) (tdelta time)))))) + (make-run-request (lambda () (kont #f)) (tdelta secs)))))) + +(define (8usleep usecs) + "Like usleep, but asynchronous." + (define (usecs->time-pair) + (if (< 1000000) + (cons 0 usecs) + (let* ((sec (floor (/ usecs 1000000))) + (msec (- usecs (* sec 1000000)))) + (cons sec msec)))) + (8sync-abort-to-prompt + (make-async-request + (lambda (kont) + (make-run-request (lambda () (kont #f)) (tdelta usecs->time-pair)))))) ;; Voluntarily yield execution (define (yield) ; @@: should this be define-inlinable?