diff options
author | 2022-04-12 00:43:23 -0700 | |
---|---|---|
committer | 2022-04-12 00:43:23 -0700 | |
commit | 9db701ab41cb1195f0ec506455840ea79be07aee (patch) | |
tree | fc22b8cd9d8f6cfb725a654d8e598f817196f816 /src/mimalloc_arena.zig | |
parent | a0f9a6ed60145dcaa2ee87f745a3dc0a0e05acfd (diff) | |
download | bun-9db701ab41cb1195f0ec506455840ea79be07aee.tar.gz bun-9db701ab41cb1195f0ec506455840ea79be07aee.tar.zst bun-9db701ab41cb1195f0ec506455840ea79be07aee.zip |
wip fixes to sendfile() blocking
Diffstat (limited to 'src/mimalloc_arena.zig')
-rw-r--r-- | src/mimalloc_arena.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mimalloc_arena.zig b/src/mimalloc_arena.zig index 70ce813a4..8b131c84a 100644 --- a/src/mimalloc_arena.zig +++ b/src/mimalloc_arena.zig @@ -11,6 +11,14 @@ const assert = std.debug.assert; pub const Arena = struct { heap: ?*mimalloc.mi_heap_t = null, + /// Internally, mimalloc calls mi_heap_get_default() + /// to get the default heap. + /// It uses pthread_getspecific to do that. + /// We can save those extra calls if we just do it once in here + pub fn getThreadlocalDefault() Allocator { + return Allocator{ .ptr = mimalloc.mi_heap_get_default(), .vtable = &c_allocator_vtable }; + } + pub fn backingAllocator(this: Arena) Allocator { var arena = Arena{ .heap = this.heap.?.backing() }; return arena.allocator(); |