[Ecls-list] Special variables and threads

Matthew Mondor mm_lists at pulsar-zone.net
Fri Jan 18 20:50:20 UTC 2013


On Fri, 18 Jan 2013 20:58:41 +0100
Peter Enerccio <enerccio at gmail.com> wrote:

> Hello, I have a question.
> Are special variables safe for multithreading?
> Ie, if one thread sets them, others will not be changed?

Because of their dynamic nature, if they are bound by a thread, they
can safely be used by that thread afterwards without interference,
indeed, as their binding becomes thread-local.  If however a dynamic
variable is used without local rebinding, you might need to also
protect their access using a lock depending on how you use them (this
then allows process-shared objects to be shared among threads and
accessed like globals).

If you however want to create them from a thread using
defparameter/defvar, I'd have to check but my guess is that ECL uses
the necessary locks internally for its own package/symbol management.
My experience is with special variables to be created before the other
threads are launched.

I hope this helps,
-- 
Matt




More information about the ecl-devel mailing list