It passes on x86 however for some reason I'm not 100% sure it is a correct 
implementation. Is there a better way of doing it?

@JCStressTest

@State
@Outcome(id = "1, 0", expect = ACCEPTABLE, desc = "first executed")
@Outcome(id = "0, 1", expect = ACCEPTABLE, desc = "second executed")
@Outcome(id = "1, 1", expect = FORBIDDEN, desc = "both executed!")
@Outcome(id = "0, 0", expect = FORBIDDEN, desc = "none executed!")
public class VolatileConcurrencyTest {

    volatile Object receiver;

    volatile Object resolution;

    AtomicBoolean applied = new AtomicBoolean();

    @Actor
    void actor1(IntResult2 r) {
        receiver = new Object();
        if (resolution != null && applied.compareAndSet(false, true)) {
            r.r1 = 1;
        } else {
            r.r1 = 0;
        }
    }

    @Actor
    void actor2(IntResult2 r) {
        resolution = new Object();
        if (receiver != null && applied.compareAndSet(false, true)) {
            r.r2 = 1;
        } else {
            r.r2 = 0;
        }
    }
}



-- 
You received this message because you are subscribed to the Google Groups 
"mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to