diff options
Diffstat (limited to 'src/memory.zig')
| -rw-r--r-- | src/memory.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/memory.zig b/src/memory.zig index 6f6c6191..7021a1bb 100644 --- a/src/memory.zig +++ b/src/memory.zig @@ -409,6 +409,15 @@ pub fn unpin(bytes: []const u8) void { } } +/// Whether the blob at `bytes.ptr` is pinned: a join's writer is still to +/// send it, so it is not written in place (File.replace). +pub fn isPinned(bytes: []const u8) bool { + if (pin_count.load(.acquire) == 0) return false; + lockPins(); + defer pins_lock.store(false, .release); + return pins.contains(@intFromPtr(bytes.ptr)); +} + /// Whether the free of `bytes` is put off (it is pinned). fn pinned(allocator: Allocator, bytes: []const u8, alignment: std.mem.Alignment) bool { if (pin_count.load(.acquire) == 0) return false; |
