the.bay.news

Confusion about releasing a resource from a future

Ziggit
Confusion about releasing a resource from a future
I’m trying to understand how to correctly manage resources when using futures. The following example does not compile: const std = @import("std"); const Io = std.Io; const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; pub fn main(init: std.process.Init) !void { const gpa = init.gpa; const io = init.io; var numbers_future = io.async(createNumbers, .{gpa}); defer if (numbers_future.cancel(io)) |numbers| numbers.deinit(gpa) else |_| {}; const numbers = try ...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.