Boost logo

Boost :

From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2003-12-30 01:27:05


"Dan W." <danw_at_[hidden]>

> Might make a nice addition to the thread library....
...
> Call create_double_buffer<my_buff_t>( new my_buff_t, new my_buff_t )
>
This is exception unsafe, btw.

> Once done, it simply lets the shared_ptr go out of scope. This triggers a
> mechanism (via custom deleter calling double_buffer::operator()()) that
moves
> the buffer along from the producer checkout and makes it available to the
> consumer.
>
Is this similar to 'synchronized' library:
http://libcalc.sourceforge.net/synchronized.hpp
?

Can you please explain in detail how thread safety is reached without using
mutexes? Is it because shared_ptr<> uses mutex inside? Is it safe against
compiler optimizations and CPU cache effects?

/Pavel


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