Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2004-07-15 18:50:52


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.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk