
"Eric Niebler" <eric@boost-consulting.com> writes:
Eric Niebler wrote:
David Abrahams wrote:
BTW, it just occurred to me that
timed_lock(m, 0)
could potentially generate different code from
timed_lock(m, some_int)
If we can detect literal zero... which I think is possible.
What about:
scoped_lock l(m); // block scoped_lock l(m, 0); // try scoped_lock l(m, 33); // timed
scoped_lock l(m, deferred); // deferred scoped_lock l(deferred(m)); // alternate ??
Interesting. That's workable.
On second thought, I think it's too subtle. You can detect literal zero, but you can't detect (at compile-time) an int with a value of zero. I'm not comfortable with this:
scoped_lock l(m, 0);
meaning something different than:
int t = 0; scoped_lock l(m, t);
Perhaps it's really OK because the effect is the same, but the fact that they would execute different code paths sets off bells in my head.
I'm not too worried. It really would be semantically identical and the timed lock code could contain a branch for the zero case if you want efficiency. It might still be too cute, but as long as we're talking about slimming the interface down we should discuss it. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com