changind atomic operations order

This commit is contained in:
2025-12-10 07:39:21 +01:00
parent 359843acdb
commit 7e19ba2fdd
2 changed files with 7 additions and 7 deletions

View File

@@ -43,25 +43,25 @@ pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
pub fn getStatus(interface: *Interface) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
if (!self.is_signaled.load(.acquire)) {
if (!self.is_signaled.load(.seq_cst)) {
return VkError.NotReady;
}
}
pub fn reset(interface: *Interface) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
self.is_signaled.store(false, .monotonic);
self.is_signaled.store(false, .seq_cst);
}
pub fn signal(interface: *Interface) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
self.is_signaled.store(true, .monotonic);
self.is_signaled.store(true, .seq_cst);
self.condition.broadcast();
}
pub fn wait(interface: *Interface, timeout: u64) VkError!void {
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
if (self.is_signaled.load(.acquire)) return;
if (self.is_signaled.load(.seq_cst)) return;
if (timeout == 0) return VkError.Timeout;
self.mutex.lock();

View File

@@ -7,11 +7,11 @@ count: std.atomic.Value(usize),
pub const init: Self = .{ .count = std.atomic.Value(usize).init(0) };
pub inline fn ref(self: *Self) void {
_ = self.count.fetchAdd(1, .monotonic);
_ = self.count.fetchAdd(1, .seq_cst);
}
pub inline fn unref(self: *Self) void {
_ = self.count.fetchSub(1, .monotonic);
_ = self.count.fetchSub(1, .seq_cst);
}
pub inline fn hasRefs(self: *Self) bool {
@@ -19,5 +19,5 @@ pub inline fn hasRefs(self: *Self) bool {
}
pub inline fn getRefsCount(self: *Self) usize {
return self.count.load(.acquire);
return self.count.load(.seq_cst);
}