Simplify (and robustify) regular PACKing
[sbcl.git] / contrib / sb-concurrency / tests / test-utils.lisp
1 ;;;; -*-  Lisp -*-
2 ;;;;
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
11
12 (in-package :sb-concurrency-test)
13
14 #+sb-thread
15 (progn
16
17 (defparameter +timeout+ 30.0)
18
19 (defun make-threads (n name fn)
20   (loop for i from 1 to n
21         collect (make-thread fn :name (format nil "~A-~D" name i))))
22
23 (defun timed-join-thread (thread &optional (timeout +timeout+))
24   (handler-case (sb-sys:with-deadline (:seconds timeout)
25                   (join-thread thread :default :aborted))
26     (sb-ext:timeout ()
27       :timeout)))
28
29 (defun hang ()
30   (join-thread *current-thread*))
31
32 (defun kill-thread (thread)
33   (when (thread-alive-p thread)
34     (ignore-errors
35       (terminate-thread thread))))
36
37 ) ;; #+sb-thread (progn ...