[Ecls-list] thread-specific data

Tobias C. Rittweiler tcr at freebits.de
Tue Mar 16 08:22:34 UTC 2010


Matthew Mondor writes:

> Hello,
>
> Is there already an existing facility permitting CL user code to bind
> thread-specific "special" or global data?  I see some code related to
> local bindings suggesting that perhaps, using LET to create a binding
> would only affect the current thread.  Should threads needing
> thread-specific globals use such bindings in a closure?

Yes. Two points here: a) many implementations provide a special variable
and a keyword parameter on MAKE-THREAD for default bindings in new
threads, b) it will create thread-local bindings, but not thread-local
data. I.e. the data will be part of the general Lisp heap, and can be
freely shared between threads.



> Or perhaps we also should add a hash table to the thread context
> structure such that we may also present an interface similar to
> pthread_[get/set]specific(3) as part of MP?  Or to introduce special
> variables which instead of being process-global would be
> thread-specific globals, i.e. using (define-mp-parameter *foo* 'bar),
> or (declare (thread-specific *foo*)) or the like?

It has not been implemented yet, but I made the suggestion on SBCL's bug
tracker to introduce a THREAD-LOCAL-VALUE special form a la
LOAD-TIME-VALUE.

  -T.





More information about the ecl-devel mailing list