Thin Lock Implementation

Steven Schveighoffer schveiguy at yahoo.com
Tue Aug 19 07:52:08 PDT 2008


"Bartosz Milewski" wrote
>I posted some implementation details of Thin Lock in my blog, 
>http://bartoszmilewski.wordpress.com/ . I would appreciate comments.
>
> And by the way, I put it on reddit too: 
> http://www.reddit.com/comments/6wmq4/thin_lock_implementation/ .
>

This looks a lot more promising than the original concept that Walter linked 
to :)

There is mention of casting away shared which throws an exception if the 
object isn't shared.  Is this the locking mechanism to both read and write 
data?  i.e. you have to cast away sharing to use the data, then cast it back 
to unshared?  How do you wait for an object to be available so you can 
unshare it?

What happens if you forget to uncast it?

What happens to subcomponents?  i.e. shared is supposed to be transitive, 
right?  So if you cast away shared in the top-level object, does that go and 
try unsharing all the objects referenced by it (i.e. setting all the 
currently shared bits to 0)?  If not, then how do you know that the 
subobjects are shared in the type system?  It looks like a lot of this is 
going to be runtime checks, or is there going to be another type modifier 
for 'created shared, but currently unshared', i.e. 'locked' or something?

Cool stuff, I think you are on the right track.

-Steve 





More information about the Digitalmars-d mailing list