|
Boost : |
From: Bill Wade (bill.wade_at_[hidden])
Date: 2000-09-08 10:06:01
> From: William Kempf [mailto:sirwillard_at_[hidden]]
> > > Uhmmm... I'd have to see a concrete example. Other than a slight
> > > performance hit I can think of no reason why the locks must
> overlap
> > > this way.
Suppose I want to implement wait()? To paraphrase, the current windows
sample code has:
wait(Lock& lock)
{
...
lock.mutex.unlock()
...
lock.mutex.lock();
...
}
Strictly speaking there is no overlap involved here. However, I believe
that you're suggesting that if I want to write wait() using the boost
interface I should use something like
wait(auto_ptr<Lock>& lock, Mutex& mutex)
{
...
lock.release();
...
lock.reset(new Lock(mutex));
...
}
Not only does this version of the code have a "slight performance hit", but
the exception safety may also be compromised. It is plausible that the
first version always succeeds. Clearly the second version may fail because
of a failure to allocate memory. The second version might also change the
dynamic type of *lock (say from a LoggingLock to a plain old Lock).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk