Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-04-18 07:20:29


Дмитрий Вьюков wrote:

> sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) // <---------
> ordinal store

There's also a hidden ordinary store to the vtable pointer. In general, when
passing an object X from thread A to thread B, you are expected to ensure
the necessary visibility (and not the author of X). Usually the queue that
you're using for message passing will contain the acquire/release pair in
pop/push. Otherwise you wouldn't be able to pass ordinary objects between
threads. Or to take a simple example:

X * px;

thread_A()
{
    store_release( &px, new X );
}

thread_B()
{
    X * p = load_acquire( &px );
    // use *p
}

The store/load part ensures the visibility of X in thread B and not X
itself.


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