mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-20 22:29:16 +02:00
31 lines
860 B
Scheme
31 lines
860 B
Scheme
|
|
(define (thread-join! thread . o)
|
|
(let ((timeout (if (pair? o) (car o) #f)))
|
|
(cond
|
|
((%thread-join! thread timeout))
|
|
(else
|
|
(thread-yield!)
|
|
(if (thread-timeout?)
|
|
(if (and (pair? o) (pair? (cdr o)))
|
|
(cadr o)
|
|
(error "timed out waiting for thread" thread)))))))
|
|
|
|
(define (thread-terminate! thread)
|
|
(if (%thread-terminate! thread) ;; need to yield if terminating ourself
|
|
(thread-yield!)))
|
|
|
|
(define (thread-sleep! timeout)
|
|
(%thread-sleep! timeout)
|
|
(thread-yield!))
|
|
|
|
(define (mutex-lock! mutex . o)
|
|
(let ((timeout (and (pair? o) (car o)))
|
|
(thread (if (and (pair? o) (pair? (cdr o))) (cadr o) #t)))
|
|
(if (not (%mutex-lock! mutex timeout thread))
|
|
(thread-yield!))))
|
|
|
|
(define (mutex-unlock! mutex . o)
|
|
#f)
|
|
|
|
(define current-time get-time-of-day)
|
|
(define time? timeval?)
|