-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy paththread.sls
33 lines (30 loc) · 1.25 KB
/
thread.sls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(library (thread)
(export)
(import (chezpart)
(rename (only (chezscheme)
sleep
printf)
[sleep chez:sleep])
(rename (core)
[core:break-enabled-key break-enabled-key]
;; These are extracted via `#%linklet`:
[make-engine core:make-engine]
[engine-block core:engine-block]
[engine-return core:engine-return]
[root-continuation-prompt-tag core:root-continuation-prompt-tag]))
(define (sleep secs)
(define isecs (inexact->exact (floor secs)))
(chez:sleep (make-time 'time-duration
(inexact->exact (floor (* (- secs isecs) 1e9)))
isecs)))
(define (primitive-table key)
(case key
[(|#%engine|) (hash
'make-engine core:make-engine
'engine-block core:engine-block
'engine-return core:engine-return
'root-continuation-prompt-tag core:root-continuation-prompt-tag
'break-enabled-key break-enabled-key
'exn:break/non-engine exn:break)]
[else #f]))
(include "linklet/thread.scm"))