1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: processes.lisp
6 ;;;; Purpose: Multiprocessing functions
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: June 2003
9 ;;;; *************************************************************************
14 (defun make-process (name func)
15 #+allegro (mp:process-run-function name func)
16 #+cmu (mp:make-process func :name name)
17 #+lispworks (mp:process-run-function name nil func)
18 #+sb-thread (sb-thread:make-thread func :name name)
19 #+ccl (ccl:process-run-function name func)
20 #-(or allegro cmu lispworks sb-thread ccl) (funcall func)
23 (defun destroy-process (process)
24 #+cmu (mp:destroy-process process)
25 #+allegro (mp:process-kill process)
26 #+sb-thread (sb-thread:destroy-thread process)
27 #+lispworks (mp:process-kill process)
28 #+ccl (ccl:process-kill process)
31 (defun make-lock (name)
32 "Make a named process lock."
33 #+abcl (ext:make-thread-lock)
34 #+allegro (mp:make-process-lock :name name)
35 #+ccl (ccl:make-lock name)
36 #+cmu (mp:make-lock name)
37 #+lispworks (mp:make-lock :name name)
38 #+sb-thread (sb-thread:make-mutex :name name)
39 #-(or lispworks abcl openmcl allegro sb-thread)
40 (declare (ignore name))
41 #-(or abcl allegro ccl cmu lispworks sb-thread)
45 (defmacro with-lock-held ((lock) &body body)
47 `(ext:with-thread-lock (,lock) ,@body)
49 `(mp:with-process-lock (,lock) ,@body)
51 `(ccl:with-lock-grabbed (,lock) ,@body)
53 `(mp:with-lock-held (,lock) ,@body)
55 `(mp:with-lock (,lock) ,@body)
57 `(sb-thread:with-recursive-lock (,lock) ,@body)
58 #-(or abcl allegro ccl cmu lispworks sb-thread)
63 (defmacro with-timeout ((seconds) &body body)
65 `(mp:with-timeout (,seconds) ,@body)
67 `(mp:with-timeout (,seconds) ,@body)
69 `(sb-ext:with-timeout ,seconds ,@body)
71 `(ccl:process-wait-with-timeout "waiting"
72 (* ,seconds ccl:*ticks-per-second*)
75 #-(or allegro cmu sb-thread ccl)
79 (defun process-sleep (n)
80 "Put thread to sleep for n seconds."
81 #+allegro (mp:process-sleep n)