1 (defmacro assert-timeout
(form)
2 (let ((ok (gensym "OK")))
8 (error "No timeout from form:~% ~S" ',form
)))))
12 (sb-sys:with-deadline
(:seconds
1)
13 (run-program "sleep" '("3") :search t
:wait t
)))
18 (handler-bind ((sb-sys:deadline-timeout
(lambda (c)
21 (sb-sys:defer-deadline
0.1 c
)))))
22 (sb-sys:with-deadline
(:seconds
1)
23 (run-program "sleep" '("2") :search t
:wait t
)))
24 (sb-sys:deadline-timeout
(c)
32 (handler-bind ((sb-sys:deadline-timeout
(lambda (c)
34 (sb-sys:defer-deadline
0.1 c
))))
35 (sb-sys:with-deadline
(:seconds
1)
36 (run-program "sleep" '("2") :search t
:wait t
)))
37 (sb-sys:deadline-timeout
(c)
42 #+(and sb-thread
(not sb-lutex
))
45 (let ((lock (sb-thread:make-mutex
))
47 (sb-thread:make-thread
(lambda ()
48 (sb-thread:get-mutex lock
)
51 (loop while waitp do
(sleep 0.01))
52 (sb-impl::with-deadline
(:seconds
1)
53 (sb-thread:get-mutex lock
))))
56 (let ((sem (sb-thread::make-semaphore
:count
0)))
57 (sb-impl::with-deadline
(:seconds
1)
58 (sb-thread::wait-on-semaphore sem
))))
61 (sb-impl::with-deadline
(:seconds
1)
62 (sb-thread:join-thread
63 (sb-thread:make-thread
(lambda () (loop (sleep 1)))))))
65 (with-test (:name
(:deadline
:futex-wait-eintr
))
66 (let ((lock (sb-thread:make-mutex
))
68 (sb-thread:make-thread
(lambda ()
69 (sb-thread:get-mutex lock
)
72 (loop while waitp do
(sleep 0.01))
73 (let ((thread (sb-thread:make-thread
75 (let ((start (get-internal-real-time)))
77 (sb-impl::with-deadline
(:seconds
1)
78 (sb-thread:get-mutex lock
))
79 (sb-sys:deadline-timeout
(x)
81 (let ((end (get-internal-real-time)))
82 (float (/ (- end start
)
83 internal-time-units-per-second
)
86 (sb-thread:interrupt-thread thread
(lambda () 42))
87 (let ((seconds-passed (sb-thread:join-thread thread
)))
88 (format t
"Deadline in ~S~%" seconds-passed
)
89 (assert (< seconds-passed
1.2)))))))