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 {
142
142
.globals = globals ,
143
143
};
144
144
NativeContext .init (& self .nat_ctx , alloc , loop , userctx );
145
- self .loopMicrotasks ();
145
+ self .startMicrotasks ();
146
146
}
147
147
148
148
pub fn deinit (self : * Env ) void {
149
+ self .stopMicrotasks ();
149
150
150
151
// v8 values
151
152
// ---------
@@ -180,13 +181,19 @@ pub const Env = struct {
180
181
self .nat_ctx .userctx = userctx ;
181
182
}
182
183
183
- fn loopMicrotasks (self : * Env ) void {
184
+ pub fn runMicrotasks (self : * const Env ) void {
184
185
self .isolate .performMicrotasksCheckpoint ();
185
- self .nat_ctx .loop .zigTimeout (1 * std .time .ns_per_ms , * Env , self , loopMicrotasks );
186
186
}
187
187
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 ();
190
197
}
191
198
192
199
// load user-defined Types into Javascript environement
You can’t perform that action at this time.
0 commit comments