diff options
author | 2022-06-29 20:52:58 -0700 | |
---|---|---|
committer | 2022-06-29 20:52:58 -0700 | |
commit | 6bc0bc2f6377e32fe15be05618d804b9a2fcaa90 (patch) | |
tree | b04fb068ca15596e897e8f50920e036179bced1b /src | |
parent | 856589bd989a796691ef9721797efe278fbf7d96 (diff) | |
download | bun-6bc0bc2f6377e32fe15be05618d804b9a2fcaa90.tar.gz bun-6bc0bc2f6377e32fe15be05618d804b9a2fcaa90.tar.zst bun-6bc0bc2f6377e32fe15be05618d804b9a2fcaa90.zip |
[misc] Helper functions to ObjectPool
Diffstat (limited to '')
-rw-r--r-- | src/pool.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/pool.zig b/src/pool.zig index 474849d5e..158214e4b 100644 --- a/src/pool.zig +++ b/src/pool.zig @@ -146,6 +146,14 @@ pub fn ObjectPool( unreachable; } + pub fn full() bool { + if (comptime max_count == 0) return false; + return data().loaded and data().count >= max_count; + } + + pub fn has() bool { + return data().loaded and data().list.first != null; + } pub fn get(allocator: std.mem.Allocator) *LinkedList.Node { if (data().loaded) { if (data().list.popFirst()) |node| { |