Files
bun.sh/src/bun.js/webcore/AutoFlusher.zig
taylor.fish 07cd45deae Refactor Zig imports and file structure (part 1) (#21270)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-22 17:51:38 -07:00

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;