X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=blobdiff_plain;f=processes.lisp;h=7017ce74e73d95f9cc8fe4fdd57e64d4919f5965;hp=0c9175fc8d8579917071789cf708e4546404be49;hb=251043d4c96c996a35cd48c4452b03fbef2ea21a;hpb=7a31a7ff629ae760d9c3e3abedf6e03605f83f23 diff --git a/processes.lisp b/processes.lisp index 0c9175f..7017ce7 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,33 +6,34 @@ ;;;; 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) + #+cmu (mp:make-process func :name name) #+lispworks (mp:process-run-function name nil func) - #+sb-thread (sb-thread:make-thread func) - #+clisp (funcall func) + #+sb-thread (sb-thread:make-thread func :name name) + #+openmcl (ccl:process-run-function name func) + #-(or allegro cmu lispworks sb-thread openmcl) (funcall func) ) (defun destroy-process (process) #+cmu (mp:destroy-process process) #+allegro (mp:process-kill process) - #+sbcl-thread (sb-thread:destroy-thread process) + #+sb-thread (sb-thread:destroy-thread process) #+lispworks (mp:process-kill process) + #+openmcl (ccl: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) + #+sb-thread (sb-thread:make-mutex :name name) + #+openmcl (ccl:make-lock name) ) (defmacro with-lock-held ((lock) &body body) @@ -42,8 +43,32 @@ `(mp:with-lock-held (,lock) ,@body) #+lispworks `(mp:with-lock (,lock) ,@body) - #+sbcl-thread + #+sb-thread `(sb-thread:with-recursive-lock (,lock) ,@body) + #+openmcl + `(ccl:with-lock-grabbed (,lock) ,@body) + #-(or allegro cmu lispworks sb-thread openmcl) + `(progn ,@body) + ) + + +(defmacro with-timeout ((seconds) &body body) + #+allegro + `(mp:with-timeout (,seconds) ,@body) + #+cmu + `(mp:with-timeout (,seconds) ,@body) + #+sb-thread + `(sb-ext:with-timeout ,seconds ,@body) + #+openmcl + `(ccl:process-wait-with-timeout "waiting" + (* ,seconds ccl:*ticks-per-second*) + #'(lambda () + ,@body) nil) + #-(or allegro cmu sb-thread openmcl) + `(progn ,@body) ) +(defun process-sleep (n) + #+allegro (mp:process-sleep n) + #-allegro (sleep n))