r5266: *** empty log message ***
[kmrcl.git] / processes.lisp
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: modlisp -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          processes.lisp
6 ;;;; Purpose:       Multiprocessing functions
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  June 2003
9 ;;;;
10 ;;;; $Id: processes.lisp,v 1.2 2003/07/09 22:12:52 kevin Exp $
11 ;;;; *************************************************************************
12
13 (in-package #:kmrcl)
14
15
16 (defun make-process (name func)
17   #+allegro (mp:process-run-function name func)
18   #+cmu (mp:make-process func :name name)
19   #+lispworks (mp:process-run-function name nil func)
20   #+sb-thread (sb-thread:make-thread func)
21   #-(or allegro cmu lispworks sb-thread) (funcall func)
22   )
23
24 (defun destroy-process (process)
25   #+cmu (mp:destroy-process process)
26   #+allegro (mp:process-kill process)
27   #+sbcl-thread (sb-thread:destroy-thread process)
28   #+lispworks (mp:process-kill process)
29   )
30
31 (defun make-lock (name)
32   #+allegro (mp:make-process-lock :name name)
33   #+cmu (mp:make-lock name)
34   #+lispworks (mp:make-lock :name name)
35   #+sbcl-thread (sb-thread:make-mutex :name name)
36   )
37
38 (defmacro with-lock-held ((lock) &body body)
39   #+allegro
40   `(mp:with-process-lock (,lock) ,@body)
41   #+cmu
42   `(mp:with-lock-held (,lock) ,@body)
43   #+lispworks
44   `(mp:with-lock (,lock) ,@body)
45   #+sbcl-thread
46   `(sb-thread:with-recursive-lock (,lock) ,@body)
47   )
48
49