
18 Apr
2007
18 Apr
'07
11:20 a.m.
Дмитрий Вьюков 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.