mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 03:48:56 +00:00
27 lines
1.1 KiB
Zig
27 lines
1.1 KiB
Zig
registered: bool = false,
|
|
|
|
pub fn registerDeferredMicrotaskWithType(comptime Type: type, this: *Type, vm: *jsc.VirtualMachine) void {
|
|
if (this.auto_flusher.registered) return;
|
|
registerDeferredMicrotaskWithTypeUnchecked(Type, this, vm);
|
|
}
|
|
|
|
pub fn unregisterDeferredMicrotaskWithType(comptime Type: type, this: *Type, vm: *jsc.VirtualMachine) void {
|
|
if (!this.auto_flusher.registered) return;
|
|
unregisterDeferredMicrotaskWithTypeUnchecked(Type, this, vm);
|
|
}
|
|
|
|
pub fn unregisterDeferredMicrotaskWithTypeUnchecked(comptime Type: type, this: *Type, vm: *jsc.VirtualMachine) void {
|
|
bun.assert(this.auto_flusher.registered);
|
|
bun.assert(vm.eventLoop().deferred_tasks.unregisterTask(this));
|
|
this.auto_flusher.registered = false;
|
|
}
|
|
|
|
pub fn registerDeferredMicrotaskWithTypeUnchecked(comptime Type: type, this: *Type, vm: *jsc.VirtualMachine) void {
|
|
bun.assert(!this.auto_flusher.registered);
|
|
this.auto_flusher.registered = true;
|
|
bun.assert(!vm.eventLoop().deferred_tasks.postTask(this, @ptrCast(&Type.onAutoFlush)));
|
|
}
|
|
|
|
const bun = @import("bun");
|
|
const jsc = bun.jsc;
|