[concurrency-interest] StampedLock

Martin Buchholz martinrb at google.com
Sun Oct 14 15:45:01 EDT 2012

In tryConvertToWriteLock:

you are already checking that the WBITs match in

        while (((s = state) & SBITS) == (stamp & SBITS)) {

so the check  a < WBIT in

            else if (m == RUNIT && a != 0L && a < WBIT) {

can be removed.


Also, it would be more consistent with other methods to throw IMSE on
"impossible" stamps

E.g. here you just have a check for invalid stamps, but
                if (a != m)
shouldn't you throw instead?

Alternatively, you could make this sharp knife even sharper and simply
assume all input stamps are always return stamps from a previous call, so
you never have both WBIT and RBITS.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20121014/8fbf214e/attachment.html>

More information about the Concurrency-interest mailing list