Ticket #1408: suspension.diff
File suspension.diff, 1.4 KB (added by , 6 years ago) |
---|
-
suspension.scm
5 5 continuation-drop 6 6 continuation-suspend 7 7 continuation-resume) 8 (import scheme chicken ports )8 (import scheme chicken ports foreign) 9 9 10 10 (use srfi-18 s11n) 11 11 … … 53 53 (lambda () (store (get-output-string o))) 54 54 continuation-drop) ) ) ) ) ) 55 55 56 (define direct-return 57 (foreign-lambda* void ((scheme-object dk) (scheme-object x)) 58 "C_kontinue(dk, x);")) 59 56 60 (define (continuation-resume k . results) 57 ( ##sys#direct-return (with-input-from-string k deserialize) results) )61 (direct-return (with-input-from-string k deserialize) results) ) 58 62 59 63 ) -
tests/simple-test.scm
4 4 5 5 (let ((args (command-line-arguments))) 6 6 (cond ((member "store" args) 7 (print "saving ...")8 7 (with-limited-continuation 9 8 (lambda () 10 9 (let ((r (continuation-suspend 11 10 (lambda (k) 11 (print "saving ...") 12 12 (with-output-to-file "k.data" (cut display k)))))) 13 13 (print "reenter: " r) 14 14 (exit))))) … … 16 16 (print "loading ...") 17 17 (continuation-resume 18 18 (with-input-from-file "k.data" read-string) 19 #f))19 123)) 20 20 (else (print "load or store?"))))