cleanup hook

This commit is contained in:
Jarred Sumner
2022-05-05 00:36:24 -07:00
parent c80e048ab3
commit d6ce585ef3
4 changed files with 111 additions and 5 deletions

View File

@@ -584,6 +584,16 @@ pub const VirtualMachine = struct {
return this.event_loop;
}
pub fn onExit(this: *VirtualMachine) void {
var rare_data = this.rare_data orelse return;
var hook = rare_data.cleanup_hook orelse return;
hook.execute();
while (hook.next) |next| {
next.execute();
hook = next;
}
}
pub const EventLoop = struct {
ready_tasks_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
pending_tasks_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),