On Wed, Jun 17, 2009 at 2:21 AM, Luke J Crookluke@balooga.com wrote:
Corman Common Lisp FFI allows a thread to be blessed. I don't know if any other Lisp supports this though.
Clozure CL seems to this automagically. Gary Byers described the issue in detail in this message http://www.clozure.com/pipermail/openmcl-devel/2003-May/004781.html. Although he says "that code isn't written yet", apparently it has been written since then.
Here's a quick test to check whether your Lisp supports callbacks from random threads.
(in-package :cffi)
(load-foreign-library "libpthread.so.0")
(defcallback foo :pointer ((arg :pointer)) (declare (ignore arg)) (print 'called-into-lisp-from-foreign-thread) (null-pointer))
(defctype pthread-t :unsigned-long)
(with-foreign-object (th 'pthread-t) (foreign-funcall "pthread_create" :pointer th :pointer (null-pointer) :pointer (callback foo) :pointer (null-pointer)) (foreign-funcall "pthread_join" pthread-t (mem-ref th 'pthread-t) :pointer (null-pointer)))
We should at some point run it on the supported Lisps and note down which ones support this. Then add that information to the manual and possibly push something informative to *FEATURES* on Lisps that don't support this.