[cpp-threads] Belated comments on N2052

Peter Dimov pdimov at mmltd.net
Mon Oct 23 23:40:38 BST 2006


* 1.9p17: the example seems incorrect; increment_x doesn't return a value, 
and the comment "x may be incremented only once" looks wrong.

* 1.10.p5: "...the value written by B is computed using the value read by 
A..."

Consider:

int r1 = atomic_load( &a );
atomic_store( &b, r1 - r1 );

Is the store really intra-thread-ordered? Every compiler worth its salt will 
optimize r1 out, breaking the data dependency.

Maybe something like "different values read by A can cause different values 
to be written by B". Similarly for the control dependency.

* 1.10p8: "for any evaluation X" is ambiguous, can mean "there exists an 
evaluation X such that..." or "for all evaluations X..."

* 17.4.4.8+ (library):

"Library calls do not introduce synchronizes-with relationships"

... unless specified otherwise?

template<class T> class concurrent_queue
{
public:

    void push( T t ); // needs to be a release
    T pop(); // needs to be an acquire
};

concurrent_queue<int*> q;

// thread 1

q.push( new int( 5 ) );

// thread 2

int * p = q.pop(); // must observe *p == 5




More information about the cpp-threads mailing list