add note to disabled tests, improve comptime cmpxchg
This commit is contained in:
@@ -38,8 +38,8 @@ pub fn Stack(comptime T: type) type {
|
||||
node.next = self.root;
|
||||
self.root = node;
|
||||
} else {
|
||||
while (@atomicRmw(bool, &self.lock, .Xchg, true, .SeqCst) != false) {}
|
||||
defer assert(@atomicRmw(bool, &self.lock, .Xchg, false, .SeqCst) == true);
|
||||
while (@atomicRmw(bool, &self.lock, .Xchg, true, .SeqCst)) {}
|
||||
defer assert(@atomicRmw(bool, &self.lock, .Xchg, false, .SeqCst));
|
||||
|
||||
node.next = self.root;
|
||||
self.root = node;
|
||||
@@ -52,8 +52,8 @@ pub fn Stack(comptime T: type) type {
|
||||
self.root = root.next;
|
||||
return root;
|
||||
} else {
|
||||
while (@atomicRmw(bool, &self.lock, .Xchg, true, .SeqCst) != false) {}
|
||||
defer assert(@atomicRmw(bool, &self.lock, .Xchg, false, .SeqCst) == true);
|
||||
while (@atomicRmw(bool, &self.lock, .Xchg, true, .SeqCst)) {}
|
||||
defer assert(@atomicRmw(bool, &self.lock, .Xchg, false, .SeqCst));
|
||||
|
||||
const root = self.root orelse return null;
|
||||
self.root = root.next;
|
||||
@@ -164,7 +164,7 @@ fn startPuts(ctx: *Context) u8 {
|
||||
|
||||
fn startGets(ctx: *Context) u8 {
|
||||
while (true) {
|
||||
const last = @atomicLoad(bool, &ctx.puts_done, .SeqCst) == true;
|
||||
const last = @atomicLoad(bool, &ctx.puts_done, .SeqCst);
|
||||
|
||||
while (ctx.stack.pop()) |node| {
|
||||
std.time.sleep(1); // let the os scheduler be our fuzz
|
||||
|
||||
@@ -169,8 +169,7 @@ pub fn Channel(comptime T: type) type {
|
||||
|
||||
lock: while (true) {
|
||||
// set the lock flag
|
||||
const prev_lock = @atomicRmw(bool, &self.dispatch_lock, .Xchg, true, .SeqCst);
|
||||
if (prev_lock != 0) return;
|
||||
if (@atomicRmw(bool, &self.dispatch_lock, .Xchg, true, .SeqCst)) return;
|
||||
|
||||
// clear the need_dispatch flag since we're about to do it
|
||||
@atomicStore(bool, &self.need_dispatch, false, .SeqCst);
|
||||
@@ -250,11 +249,9 @@ pub fn Channel(comptime T: type) type {
|
||||
}
|
||||
|
||||
// clear need-dispatch flag
|
||||
const need_dispatch = @atomicRmw(bool, &self.need_dispatch, .Xchg, false, .SeqCst);
|
||||
if (need_dispatch) continue;
|
||||
if (@atomicRmw(bool, &self.need_dispatch, .Xchg, false, .SeqCst)) continue;
|
||||
|
||||
const my_lock = @atomicRmw(bool, &self.dispatch_lock, .Xchg, false, .SeqCst);
|
||||
assert(my_lock);
|
||||
assert(@atomicRmw(bool, &self.dispatch_lock, .Xchg, false, .SeqCst));
|
||||
|
||||
// we have to check again now that we unlocked
|
||||
if (@atomicLoad(bool, &self.need_dispatch, .SeqCst)) continue :lock;
|
||||
|
||||
Reference in New Issue
Block a user