added libguardians.ss

This commit is contained in:
Abdulaziz Ghuloum 2006-12-19 20:15:36 +03:00
parent 5ccca042a6
commit f7aa4c99e1
1 changed files with 20 additions and 0 deletions

20
src/libguardians.ss Normal file
View File

@ -0,0 +1,20 @@
(let ()
(define make-guardian
(lambda ()
(let ([tc
(let ([x (cons #f #f)])
(cons x x))])
(case-lambda
[()
(and (not (eq? (car tc) (cdr tc)))
(let ([x (car tc)])
(let ([y (car x)])
(set-car! tc (cdr x))
(set-car! x #f)
(set-cdr! x #f)
y)))]
[(obj)
(foreign-call "ikrt_register_guardian" tc obj)
(void)]))))
(primitive-set! 'make-guardian make-guardian))