Walter is right about transitive readonly - here's the alternative

Steven Schveighoffer schveiguy at yahoo.com
Thu Sep 13 14:34:34 PDT 2007


"Janice Caron" wrote
> On 9/13/07, Sean Kelly <sean at f4.ca> wrote:
>> (in fact, POSIX has this feature)
>
> I wonder how. If it's implemented as release the read lock followed by
> obtain a write lock, then the caller must beware that another thread
> may have written /during/ the upgrade.

In fact, I think that IS the case.  If you upgrade, and you didn't get it 
first, the lock fails, and you no longer hold the read lock.

The advantage here is that if you ARE the first writer to gain the lock, you 
can avoid the second read to see if anything's changed since you got the 
read lock.

However, I think that is negated by the fact that you will STILL have to 
have code in case you don't get it first.  Not worth it in my opinion.

-Steve 





More information about the Digitalmars-d mailing list