X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=processes.lisp;h=7bdf018e6084324dec584bc1c104e613950928f4;hp=547b862bafcf9b195c1916034af2a5a864ac49c4;hb=3ca593ad0ad02da7ebfd270523795674d6458ad3;hpb=0dc565c13310ce9f59b42b4e4bdd9167e24ca756 diff --git a/processes.lisp b/processes.lisp index 547b862..7bdf018 100644 --- a/processes.lisp +++ b/processes.lisp @@ -1,4 +1,4 @@ -;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: modlisp -*- +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; @@ -6,8 +6,6 @@ ;;;; Purpose: Multiprocessing functions ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: June 2003 -;;;; -;;;; $Id: processes.lisp,v 1.3 2003/07/11 02:37:33 kevin Exp $ ;;;; ************************************************************************* (in-package #:kmrcl) @@ -17,34 +15,47 @@ #+allegro (mp:process-run-function name func) #+cmu (mp:make-process func :name name) #+lispworks (mp:process-run-function name nil func) - #+sb-thread (sb-thread:make-thread func) - #-(or allegro cmu lispworks sb-thread) (funcall func) + #+sb-thread (sb-thread:make-thread func :name name) + #+ccl (ccl:process-run-function name func) + #-(or allegro cmu lispworks sb-thread ccl) (funcall func) ) (defun destroy-process (process) #+cmu (mp:destroy-process process) #+allegro (mp:process-kill process) - #+sb-thread (sb-thread:destroy-thread process) + #+sb-thread (sb-thread:terminate-thread process) #+lispworks (mp:process-kill process) + #+ccl (ccl:process-kill process) ) (defun make-lock (name) + "Make a named process lock." + #+abcl (ext:make-thread-lock) #+allegro (mp:make-process-lock :name name) + #+ccl (ccl:make-lock name) #+cmu (mp:make-lock name) #+lispworks (mp:make-lock :name name) - #+sbcl-thread (sb-thread:make-mutex :name name) - ) + #+sb-thread (sb-thread:make-mutex :name name) + #-(or lispworks abcl openmcl allegro sb-thread) + (declare (ignore name)) + #-(or abcl allegro ccl cmu lispworks sb-thread) + nil) + (defmacro with-lock-held ((lock) &body body) + #+abcl + `(ext:with-thread-lock (,lock) ,@body) #+allegro `(mp:with-process-lock (,lock) ,@body) + #+ccl + `(ccl:with-lock-grabbed (,lock) ,@body) #+cmu `(mp:with-lock-held (,lock) ,@body) #+lispworks `(mp:with-lock (,lock) ,@body) - #+sbcl-thread + #+sb-thread `(sb-thread:with-recursive-lock (,lock) ,@body) - #-(or allegro cmu lispworks sbcl-thread) + #-(or abcl allegro ccl cmu lispworks sb-thread) `(progn ,@body) ) @@ -54,9 +65,18 @@ `(mp:with-timeout (,seconds) ,@body) #+cmu `(mp:with-timeout (,seconds) ,@body) - #+sbcl-thread + #+sb-thread `(sb-ext:with-timeout ,seconds ,@body) - #-(or allegro cmu sbcl-thread) + #+ccl + `(ccl:process-wait-with-timeout "waiting" + (* ,seconds ccl:*ticks-per-second*) + #'(lambda () + ,@body) nil) + #-(or allegro cmu sb-thread ccl) `(progn ,@body) ) - + +(defun process-sleep (n) + "Put thread to sleep for n seconds." + #+allegro (mp:process-sleep n) + #-allegro (sleep n))