aboutsummaryrefslogtreecommitdiff
path: root/src/hive_array.zig
diff options
context:
space:
mode:
authorGravatar Ciro Spaciari <ciro.spaciari@gmail.com> 2023-04-28 17:40:44 -0300
committerGravatar GitHub <noreply@github.com> 2023-04-28 13:40:44 -0700
commit4515a6373e22246e2ec6df4475dc63a965bf9c4a (patch)
treeb7a3dd436ecbbef454468ed71a7583ee590e16f7 /src/hive_array.zig
parentc383638ddd0b220c482e2e0ec7baa2f650d05776 (diff)
downloadbun-4515a6373e22246e2ec6df4475dc63a965bf9c4a.tar.gz
bun-4515a6373e22246e2ec6df4475dc63a965bf9c4a.tar.zst
bun-4515a6373e22246e2ec6df4475dc63a965bf9c4a.zip
Improves Body.Value life cycle and Signal life cycle on server.zig (#2752)
* reestruct request body value and signal * revert react-hello-world * fix constructInto and test * fmt * fix body nullable * Request can outlive RequestContext * fmt * BodyValue is now HiveRef * hasDecl for Ref and HiveRef * fix deinit call on Ref/HiveRef * adds InlineBlob * fix Bun.inspect when using InlineBlob * revert InlineBlob * Fix mimalloc-debug * Add TODO note * fix: make node:crypto Hash.copy work correctly (#2761) This commit will also: - add a CryptoHasher.copy function - make CryptoHasher.digest reset the hasher so it can be reused Resolves #2651 * :nail_care: * address unicode issue (#2763) * Fix an oopsie * Another oopsie * use inline for * Fixup --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> * Request can outlive RequestContext * fmt * garantee to have the abort signnal attached to the server before abort the client on bun-server test --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Silver <14016168+silversquirl@users.noreply.github.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Diffstat (limited to 'src/hive_array.zig')
-rw-r--r--src/hive_array.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/hive_array.zig b/src/hive_array.zig
index 39f10d324..cc032c44f 100644
--- a/src/hive_array.zig
+++ b/src/hive_array.zig
@@ -86,6 +86,14 @@ pub fn HiveArray(comptime T: type, comptime capacity: u16) type {
return self.allocator.create(T) catch unreachable;
}
+ pub fn tryGet(self: *This) !*T {
+ if (self.hive.get()) |value| {
+ return value;
+ }
+
+ return try self.allocator.create(T);
+ }
+
pub fn put(self: *This, value: *T) void {
if (self.hive.put(value)) return;