r5259: *** empty log message ***
[kmrcl.git] / processes.lisp
diff --git a/processes.lisp b/processes.lisp
new file mode 100644 (file)
index 0000000..0c9175f
--- /dev/null
@@ -0,0 +1,49 @@
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: modlisp -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name:          processes.lisp
+;;;; Purpose:       Multiprocessing functions
+;;;; Programmer:    Kevin M. Rosenberg
+;;;; Date Started:  June 2003
+;;;;
+;;;; $Id: processes.lisp,v 1.1 2003/07/08 16:12:40 kevin Exp $
+;;;; *************************************************************************
+
+(in-package #:kmrcl)
+
+
+(defun make-process (name func)
+  #+cmu (mp:make-process func :name name)
+  #+allegro (mp:process-run-function name func)
+  #+lispworks (mp:process-run-function name nil func)
+  #+sb-thread (sb-thread:make-thread func)
+  #+clisp (funcall func)
+  )
+
+(defun destroy-process (process)
+  #+cmu (mp:destroy-process process)
+  #+allegro (mp:process-kill process)
+  #+sbcl-thread (sb-thread:destroy-thread process)
+  #+lispworks (mp:process-kill process)
+  )
+
+(defun make-lock (name)
+  #+allegro (mp:make-process-lock :name name)
+  #+cmu (mp:make-lock name)
+  #+lispworks (mp:make-lock :name name)
+  #+sbcl-thread (sb-thread:make-mutex :name name)
+  )
+
+(defmacro with-lock-held ((lock) &body body)
+  #+allegro
+  `(mp:with-process-lock (,lock) ,@body)
+  #+cmu
+  `(mp:with-lock-held (,lock) ,@body)
+  #+lispworks
+  `(mp:with-lock (,lock) ,@body)
+  #+sbcl-thread
+  `(sb-thread:with-recursive-lock (,lock) ,@body)
+  )
+
+