[closer-devel] ContextL & multithreading

Pascal Costanza pc at p-cos.net
Sun Dec 16 22:05:09 UTC 2007


Hi,

OK, my previous attempt to make ContextL thread-safe was probably a  
bit too optimistic. The current darcs repository has a new version  
with more coarse-grained locks.

Background: For activating a layer, ContextL may have to  
programmatically create new classes on the fly. This affects the  
internal representation of the CLOS hierarchy and the Common Lisp type  
system, which are global resources.

With the old locking scheme, it could happen that two independent  
threads create new layers, creating two classes at, more or less, the  
same time, and thus leading to possible threading conflicts. (I don't  
know whether that was actually ever the case. The CLOS specification  
is unclear about this, but better be safe than sorry, as they say.)

The new locking scheme now ensures that ContextL only ever creates one  
new class at a time. This shouldn't be too problematic because after a  
while, the number of possible layer combinations should stabilize and  
new classes should actually not be necessary anymore. So in the medium  
to long run, performance shouldn't suffer from this.

I have also made another change on the fly which should ensure that  
adjoin-layer, remove-layer, ensure-active-layer and ensure-inactive- 
layer are more efficient because they now avoid unnecessary locking if  
a particular layer combination already exists.


Best,
Pascal

-- 
Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net
Vrije Universiteit Brussel, Programming Technology Lab
Pleinlaan 2, B-1050 Brussel, Belgium







More information about the closer-devel mailing list