aboutsummaryrefslogtreecommitdiff
path: root/src/install/npm.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/install/npm.zig')
-rw-r--r--src/install/npm.zig46
1 files changed, 1 insertions, 45 deletions
diff --git a/src/install/npm.zig b/src/install/npm.zig
index 9d12255d4..a6cded5dc 100644
--- a/src/install/npm.zig
+++ b/src/install/npm.zig
@@ -26,51 +26,7 @@ const SlicedString = Semver.SlicedString;
const FileSystem = @import("../fs.zig").FileSystem;
const VersionSlice = @import("./install.zig").VersionSlice;
-fn ObjectPool(comptime Type: type, comptime Init: (fn (allocator: *std.mem.Allocator) anyerror!Type), comptime threadsafe: bool) type {
- return struct {
- const LinkedList = std.SinglyLinkedList(Type);
- const Data = if (threadsafe)
- struct {
- pub threadlocal var list: LinkedList = undefined;
- pub threadlocal var loaded: bool = false;
- }
- else
- struct {
- pub var list: LinkedList = undefined;
- pub var loaded: bool = false;
- };
-
- const data = Data;
-
- pub fn get(allocator: *std.mem.Allocator) *LinkedList.Node {
- if (data.loaded) {
- if (data.list.popFirst()) |node| {
- node.data.reset();
- return node;
- }
- }
-
- var new_node = allocator.create(LinkedList.Node) catch unreachable;
- new_node.* = LinkedList.Node{
- .data = Init(
- allocator,
- ) catch unreachable,
- };
-
- return new_node;
- }
-
- pub fn release(node: *LinkedList.Node) void {
- if (data.loaded) {
- data.list.prepend(node);
- return;
- }
-
- data.list = LinkedList{ .first = node };
- data.loaded = true;
- }
- };
-}
+const ObjectPool = @import("../pool.zig").ObjectPool;
const Npm = @This();