Skip to content

Commit

Permalink
fix(sync): shared pointer window defer lock should be unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
dnut committed Dec 20, 2024
1 parent 9a1f0fc commit d6c86a6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sync/shared_memory.zig
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn SharedPointerWindow(
/// call `release` when you're done with the pointer
pub fn get(self: *Self, index: usize) ?*const T {
self.lock.lockShared();
defer self.lock.lockShared();
defer self.lock.unlockShared();

if (self.window.get(index)) |element| {
return element.acquire().payload();
Expand All @@ -81,7 +81,7 @@ pub fn SharedPointerWindow(
/// call `release` when you're done with the pointer
pub fn contains(self: *Self, index: usize) bool {
self.lock.lockShared();
defer self.lock.lockShared();
defer self.lock.unlockShared();

return self.window.contains(index);
}
Expand All @@ -91,7 +91,7 @@ pub fn SharedPointerWindow(

const items_to_release = blk: {
self.lock.lock();
defer self.lock.lock();
defer self.lock.unlock();

self.center.store(new_center, .monotonic);
break :blk self.window.realignGet(new_center, self.discard_buf);
Expand Down

0 comments on commit d6c86a6

Please sign in to comment.