From: Sam S. <sd...@gn...> - 2010-02-12 16:31:30
|
Yue Li wrote: > I understand your concern in the link, and thanks for the > implementation. The problem I'm facing is to call this thread-join > from OpenAxiom. Seems that I have to first add the implementation to > the MT package, then rebuild Clisp, and rebuild OpenAxiom on top of > it. I don't have any experience on modifying Clisp's code, is there > any way for me to add that implementation to MT quickly? Yes. This is untested: (defvar *thread-join-mutex* nil) (defconstant +original-make-thread+ (fdefinition 'mt:make-thread)) (defun make-thread (function name) (funcall +original-make-thread+ (lambda () (let ((*thread-join-mutex* (mt:make-mutex))) (mt:with-mutex-lock (*thread-join-mutex*) (funcall function)))) :name name :initial-bindings mt:*default-special-bindings*)) (defun thread-join (thread) (loop while (mt:thread-active-p thread) do (let ((jmx (mt:symbol-value-thread '*thread-join-mutex* thread))) (when jmx ; mutex may have not been created (mt:mutex-lock jmx) ; wait ; give chance other threads to wait/join as well (mt:mutex-unlock jmx))))) However, note that the CLISP MT functionality have not been finalized yet, so this code might not be actually needed when MT is released. |