1 Dec 2006 02:33
Re: [boost.thread] Atomic condition notify/wait on anothercondition
Matt Hurd <matthurd <at> acm.org>
2006-12-01 01:33:37 GMT
2006-12-01 01:33:37 GMT
>On 01/12/06, Yuval Ronen <ronen_yuval <at> yahoo.com> wrote:
<snip>
> If there aren't any, then why
> wouldn't the CV interface be changed to do the while loop itself:
>
> template <typename Lock, typename Pred>
> void condition::wait(Lock &lock, Pred while_cond)
> {
> while (while_cond)
> {
> old_wait(lock);
> }
> }
>
> or something similar.
>
> Does that make sense?
Good sense. It is so:
>From http://www.boost.org/doc/html/condition.html
#2 template<typename ScopedLock, typename Pred>
void wait(ScopedLock& lock, Pred pred);
Requires: ScopedLock meets the ScopedLock requirements and the return
from pred() is convertible to bool.
Effects: As if: while (!pred()) wait(lock)
Throws: lock_error if !lock.locked()
(Continue reading)
) and I'd propose a different interface for that
feature today:
Actually, I don't think that parametrized deletion belongs into the interface of
a smart pointer. It's up to other components to have proper deletion semantics.
Still, there sure are cases (dealing with third-party or plain C components)
where it is a practical thing to have. So I'd probably ask for a freestanding
function that is called without qualification to do the deletion (just using
delete by default), so it can be overloaded and found via ADL and we don't need
to change and mess up the interface of the smart pointer.
BTW. I just noticed there is some "get_deleter logic" (marked as experimental in
a comment) based on RTTI in 'shared_ptr.hpp'. What's that all about? Heap
selection when using shared libraries?
Regards,
Tobias
RSS Feed