[Openmcl-devel] 3 questions - TLS the default? global thread-shared vars? .CDB gen broken?

Daniel Weinreb dlw at itasoftware.com
Tue Mar 22 10:33:00 PDT 2011



Raffael Cavallaro wrote:
> On Mar 19, 2011, at 1:09 AM, Jason E. Aten wrote:
>
>   
>> In order words, when two different threads need to be able to name the same variable (after locking the thread inspects the shared variable, possibly updates it, then releases the lock), how do I tell lisp this is what I'd like?
>>     
>
> See section 4.8 of the documentation "Static Variables"
>
> e.g., (defstatic *foo* 3)
>
> It's an error to dynamically rebind a static variable; its value is always the same across all threads. Naturally, as you suggest, you'll want to avoid race conditions by using a lock or semaphore.
>
>   
By the way, defstatic is not part of the Common Lisp standard.
It is provided by CCL ("OpenMCL"), but I have no idea which
other Common Lisp implementations support it.  This may or
may not matter to you.  If you need to port to a Common
Lisp dialect that doesn't have defstatic, you can simply
change it (perhaps under read-time conditionalization
or using a macro) to another form, such as defparameter
or defvar depending on how you're using it, so you
are not painting yourself into a corner by using
defstatic.

-- Dan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20110322/b7c30a3d/attachment.htm>


More information about the Openmcl-devel mailing list