Skip to content

Commit

Permalink
Add control.timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
shirok committed Jan 18, 2025
1 parent 2556cb3 commit 09ee1e0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2025-01-17 Shiro Kawai <[email protected]>

* lib/control/timeout.scm: Added experimentally.

2025-01-15 Shiro Kawai <[email protected]>

* lib/math/prime.scm (grouped-factorize, reduced-totient): Added.
Expand Down
3 changes: 2 additions & 1 deletion lib/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ SCMFILES = \
r7rs-setup.scm \
binary/ftype.scm binary/pack.scm \
control/cseq.scm control/future.scm control/job.scm control/plumbing.scm \
control/pmap.scm control/scheduler.scm control/thread-pool.scm \
control/pmap.scm control/scheduler.scm control/timeout.scm \
control/thread-pool.scm \
dbi.scm dbd/null.scm dbm.scm dbm/fsdbm.scm dbm/dump dbm/restore \
data/cache.scm data/heap.scm \
data/ideque.scm data/imap.scm data/priority-map.scm data/random.scm \
Expand Down
21 changes: 21 additions & 0 deletions test/control.scm
Original file line number Diff line number Diff line change
Expand Up @@ -689,4 +689,25 @@
(port-closed? outlet0))
)

;;--------------------------------------------------------------------
;; control.timeout
;;

(test-section "control.timeout")
(use control.timeout)
(use srfi.19)
(test-module 'control.timeout)

(test* "timeout (not)" 'ok
(do/timeout (10 'oops) (sys-nanosleep 10) 'ok))

(test* "timeout (timeout)" 'oops
(do/timeout (0.1 'oops) (sys-sleep 1) 'ok))

(test* "timeout (already passed)" 'oops
(do/timeout ((subtract-duration (current-time)
(make-time time-duration 0 1))
'oops)
(sys-sleep 1) 'ok))

(test-end)

0 comments on commit 09ee1e0

Please sign in to comment.