File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -142,10 +142,11 @@ pub const Env = struct {
142142 .globals = globals ,
143143 };
144144 NativeContext .init (& self .nat_ctx , alloc , loop , userctx );
145- self .loopMicrotasks ();
145+ self .startMicrotasks ();
146146 }
147147
148148 pub fn deinit (self : * Env ) void {
149+ self .stopMicrotasks ();
149150
150151 // v8 values
151152 // ---------
@@ -180,13 +181,19 @@ pub const Env = struct {
180181 self .nat_ctx .userctx = userctx ;
181182 }
182183
183- fn loopMicrotasks (self : * Env ) void {
184+ pub fn runMicrotasks (self : * const Env ) void {
184185 self .isolate .performMicrotasksCheckpoint ();
185- self .nat_ctx .loop .zigTimeout (1 * std .time .ns_per_ms , * Env , self , loopMicrotasks );
186186 }
187187
188- pub fn runMicrotasks (self : * Env ) void {
189- self .isolate .performMicrotasksCheckpoint ();
188+ fn startMicrotasks (self : * Env ) void {
189+ self .runMicrotasks ();
190+ self .nat_ctx .loop .zigTimeout (1 * std .time .ns_per_ms , * Env , self , startMicrotasks );
191+ }
192+
193+ fn stopMicrotasks (self : * const Env ) void {
194+ // We force a loop reset for all zig callback.
195+ // The goal is to stop the callbacks used for the run micro tasks.
196+ self .nat_ctx .loop .resetZig ();
190197 }
191198
192199 // load user-defined Types into Javascript environement
You can’t perform that action at this time.
0 commit comments