diff options
author | 2023-08-29 15:31:06 -0700 | |
---|---|---|
committer | 2023-08-29 15:31:06 -0700 | |
commit | 5d84ef778066a6221630d82b7dc6b01aeddc3c26 (patch) | |
tree | 228e1ebae88207679fb60e08afce7b7656609758 | |
parent | a77ed151afd9ae946b500c3bac6cf1fdb18550ad (diff) | |
download | bun-5d84ef778066a6221630d82b7dc6b01aeddc3c26.tar.gz bun-5d84ef778066a6221630d82b7dc6b01aeddc3c26.tar.zst bun-5d84ef778066a6221630d82b7dc6b01aeddc3c26.zip |
Rename `uws_event_loop` to `event_loop_handle`
-rw-r--r-- | src/bun.js/api/bun.zig | 10 | ||||
-rw-r--r-- | src/bun.js/api/bun/dns_resolver.zig | 6 | ||||
-rw-r--r-- | src/bun.js/api/bun/subprocess.zig | 6 | ||||
-rw-r--r-- | src/bun.js/api/server.zig | 2 | ||||
-rw-r--r-- | src/bun.js/base.zig | 18 | ||||
-rw-r--r-- | src/bun.js/event_loop.zig | 28 | ||||
-rw-r--r-- | src/bun.js/javascript.zig | 10 | ||||
-rw-r--r-- | src/bun.js/test/jest.zig | 2 | ||||
-rw-r--r-- | src/bun.js/web_worker.zig | 4 | ||||
-rw-r--r-- | src/bun.js/webcore/streams.zig | 4 | ||||
-rw-r--r-- | src/bun_js.zig | 6 | ||||
-rw-r--r-- | src/cli/test_command.zig | 2 | ||||
-rw-r--r-- | src/http/websocket_http_client.zig | 12 |
13 files changed, 55 insertions, 55 deletions
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index cf984c81a..f86031caf 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -3325,7 +3325,7 @@ pub const Timer = struct { if (val.did_unref_timer) { val.did_unref_timer = false; - vm.uws_event_loop.?.num_polls += 1; + vm.event_loop_handle.?.num_polls += 1; } } } @@ -3398,7 +3398,7 @@ pub const Timer = struct { .callback = JSC.Strong.create(callback, globalThis), .globalThis = globalThis, .timer = uws.Timer.create( - vm.uws_event_loop.?, + vm.event_loop_handle.?, id, ), }; @@ -3444,7 +3444,7 @@ pub const Timer = struct { if (!val.did_unref_timer) { val.did_unref_timer = true; - vm.uws_event_loop.?.num_polls -= 1; + vm.event_loop_handle.?.num_polls -= 1; } } } @@ -3597,7 +3597,7 @@ pub const Timer = struct { this.timer.deinit(); // balance double unreffing in doUnref - vm.uws_event_loop.?.num_polls += @as(i32, @intFromBool(this.did_unref_timer)); + vm.event_loop_handle.?.num_polls += @as(i32, @intFromBool(this.did_unref_timer)); this.callback.deinit(); this.arguments.deinit(); @@ -3653,7 +3653,7 @@ pub const Timer = struct { .callback = JSC.Strong.create(callback, globalThis), .globalThis = globalThis, .timer = uws.Timer.create( - vm.uws_event_loop.?, + vm.event_loop_handle.?, Timeout.ID{ .id = id, .kind = kind, diff --git a/src/bun.js/api/bun/dns_resolver.zig b/src/bun.js/api/bun/dns_resolver.zig index 9c0bc8543..7364c2ffa 100644 --- a/src/bun.js/api/bun/dns_resolver.zig +++ b/src/bun.js/api/bun/dns_resolver.zig @@ -122,7 +122,7 @@ const LibInfo = struct { request.backend.libinfo.file_poll = bun.JSC.FilePoll.init(this.vm, std.math.maxInt(i32) - 1, .{}, GetAddrInfoRequest, request); std.debug.assert( request.backend.libinfo.file_poll.?.registerWithFd( - this.vm.uws_event_loop.?, + this.vm.event_loop_handle.?, .machport, true, @intFromPtr(request.backend.libinfo.machport), @@ -1656,10 +1656,10 @@ pub const DNSResolver = struct { var poll = poll_entry.value_ptr.*.?; if (readable and !poll.flags.contains(.poll_readable)) - _ = poll.register(vm.uws_event_loop.?, .readable, false); + _ = poll.register(vm.event_loop_handle.?, .readable, false); if (writable and !poll.flags.contains(.poll_writable)) - _ = poll.register(vm.uws_event_loop.?, .writable, false); + _ = poll.register(vm.event_loop_handle.?, .writable, false); } const DNSQuery = struct { diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig index 77cf3886e..2ee94a222 100644 --- a/src/bun.js/api/bun/subprocess.zig +++ b/src/bun.js/api/bun/subprocess.zig @@ -1404,7 +1404,7 @@ pub const Subprocess = struct { var poll = JSC.FilePoll.init(jsc_vm, watchfd, .{}, Subprocess, subprocess); subprocess.poll_ref = poll; switch (subprocess.poll_ref.?.register( - jsc_vm.uws_event_loop.?, + jsc_vm.event_loop_handle.?, .process, true, )) { @@ -1467,7 +1467,7 @@ pub const Subprocess = struct { var poll = JSC.FilePoll.init(jsc_vm, watchfd, .{}, Subprocess, subprocess); subprocess.poll_ref = poll; switch (subprocess.poll_ref.?.register( - jsc_vm.uws_event_loop.?, + jsc_vm.event_loop_handle.?, .process, true, )) { @@ -1530,7 +1530,7 @@ pub const Subprocess = struct { pub fn watch(this: *Subprocess) void { if (this.poll_ref) |poll| { _ = poll.register( - this.globalThis.bunVM().uws_event_loop.?, + this.globalThis.bunVM().event_loop_handle.?, .process, true, ); diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index ffe24f0f6..acb0b1a10 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -5399,7 +5399,7 @@ pub fn NewServer(comptime NamespaceType: type, comptime ssl_enabled_: bool, comp } this.listener = socket; - this.vm.uws_event_loop = uws.Loop.get(); + this.vm.event_loop_handle = uws.Loop.get(); } pub fn ref(this: *ThisServer) void { diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig index 44f33d670..c59d3111f 100644 --- a/src/bun.js/base.zig +++ b/src/bun.js/base.zig @@ -1640,7 +1640,7 @@ pub const PollRef = struct { if (this.status != .active) return; this.status = .inactive; - vm.uws_event_loop.?.unref(); + vm.event_loop_handle.?.unref(); } /// From another thread, Prevent a poll from keeping the process alive. @@ -1648,7 +1648,7 @@ pub const PollRef = struct { if (this.status != .active) return; this.status = .inactive; - vm.uws_event_loop.?.unrefConcurrently(); + vm.event_loop_handle.?.unrefConcurrently(); } /// Prevent a poll from keeping the process alive on the next tick. @@ -1672,7 +1672,7 @@ pub const PollRef = struct { if (this.status != .inactive) return; this.status = .active; - vm.uws_event_loop.?.ref(); + vm.event_loop_handle.?.ref(); } /// Allow a poll to keep the process alive. @@ -1680,7 +1680,7 @@ pub const PollRef = struct { if (this.status != .inactive) return; this.status = .active; - vm.uws_event_loop.?.refConcurrently(); + vm.event_loop_handle.?.refConcurrently(); } pub fn refConcurrentlyFromEventLoop(this: *PollRef, loop: *JSC.EventLoop) void { @@ -1801,7 +1801,7 @@ pub const FilePoll = struct { } pub fn deinitWithVM(this: *FilePoll, vm: *JSC.VirtualMachine) void { - var loop = vm.uws_event_loop.?; + var loop = vm.event_loop_handle.?; this.deinitWithoutVM(loop, vm.rareData().filePolls(vm)); } @@ -1971,7 +1971,7 @@ pub const FilePoll = struct { return; this.flags.insert(.disable); - vm.uws_event_loop.?.active -= @as(u32, @intFromBool(this.flags.contains(.has_incremented_poll_count))); + vm.event_loop_handle.?.active -= @as(u32, @intFromBool(this.flags.contains(.has_incremented_poll_count))); } pub fn enableKeepingProcessAlive(this: *FilePoll, vm: *JSC.VirtualMachine) void { @@ -1979,7 +1979,7 @@ pub const FilePoll = struct { return; this.flags.remove(.disable); - vm.uws_event_loop.?.active += @as(u32, @intFromBool(this.flags.contains(.has_incremented_poll_count))); + vm.event_loop_handle.?.active += @as(u32, @intFromBool(this.flags.contains(.has_incremented_poll_count))); } pub fn canActivate(this: *const FilePoll) bool { @@ -2035,7 +2035,7 @@ pub const FilePoll = struct { if (!this.canUnref()) return; log("unref", .{}); - this.deactivate(vm.uws_event_loop.?); + this.deactivate(vm.event_loop_handle.?); } /// Allow a poll to keep the process alive. @@ -2043,7 +2043,7 @@ pub const FilePoll = struct { if (this.canRef()) return; log("ref", .{}); - this.activate(vm.uws_event_loop.?); + this.activate(vm.event_loop_handle.?); } pub fn onTick(loop: *uws.Loop, tagged_pointer: ?*anyopaque) callconv(.C) void { diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig index 896297060..1a8732318 100644 --- a/src/bun.js/event_loop.zig +++ b/src/bun.js/event_loop.zig @@ -276,9 +276,9 @@ pub const JSCScheduler = struct { JSC.markBinding(@src()); if (delta > 0) { - jsc_vm.uws_event_loop.?.refConcurrently(); + jsc_vm.event_loop_handle.?.refConcurrently(); } else { - jsc_vm.uws_event_loop.?.unrefConcurrently(); + jsc_vm.event_loop_handle.?.unrefConcurrently(); } } @@ -375,7 +375,7 @@ pub const GarbageCollectionController = struct { gc_repeating_timer_fast: bool = true, pub fn init(this: *GarbageCollectionController, vm: *VirtualMachine) void { - var actual = vm.uws_event_loop.?; + var actual = vm.event_loop_handle.?; this.gc_timer = uws.Timer.createFallthrough(actual, this); this.gc_repeating_timer = uws.Timer.createFallthrough(actual, this); @@ -526,7 +526,7 @@ pub const EventLoop = struct { pub fn tickWhilePaused(this: *EventLoop, done: *bool) void { while (!done.*) { - this.virtual_machine.uws_event_loop.?.tick(); + this.virtual_machine.event_loop_handle.?.tick(); } } @@ -720,7 +720,7 @@ pub const EventLoop = struct { pub fn autoTick(this: *EventLoop) void { var ctx = this.virtual_machine; - var loop = ctx.uws_event_loop.?; + var loop = ctx.event_loop_handle.?; // Some tasks need to keep the event loop alive for one more tick. // We want to keep the event loop alive long enough to process those ticks and any microtasks @@ -743,7 +743,7 @@ pub const EventLoop = struct { pub fn tickPossiblyForever(this: *EventLoop) void { var ctx = this.virtual_machine; - var loop = ctx.uws_event_loop.?; + var loop = ctx.event_loop_handle.?; const pending_unref = ctx.pending_unref_counter; if (pending_unref > 0) { @@ -770,7 +770,7 @@ pub const EventLoop = struct { } pub fn autoTickActive(this: *EventLoop) void { - var loop = this.virtual_machine.uws_event_loop.?; + var loop = this.virtual_machine.event_loop_handle.?; var ctx = this.virtual_machine; @@ -822,7 +822,7 @@ pub const EventLoop = struct { ctx.global.vm().releaseWeakRefs(); ctx.global.vm().drainMicrotasks(); - var loop = ctx.uws_event_loop orelse return; + var loop = ctx.event_loop_handle orelse return; if (loop.active > 0 or (ctx.us_loop_reference_count > 0 and !ctx.is_us_loop_entered and (loop.num_polls > 0 or this.start_server_on_next_tick))) { if (this.tickConcurrentWithCount() > 0) { @@ -881,11 +881,11 @@ pub const EventLoop = struct { while (this.tasks.count > 0) { this.tick(); - if (this.virtual_machine.uws_event_loop != null) { + if (this.virtual_machine.event_loop_handle != null) { this.runUSocketsLoop(); } } else { - if (this.virtual_machine.uws_event_loop != null) { + if (this.virtual_machine.event_loop_handle != null) { this.runUSocketsLoop(); } } @@ -897,7 +897,7 @@ pub const EventLoop = struct { pub fn enqueueTaskWithTimeout(this: *EventLoop, task: Task, timeout: i32) void { // TODO: make this more efficient! - var loop = this.virtual_machine.uws_event_loop orelse @panic("EventLoop.enqueueTaskWithTimeout: uSockets event loop is not initialized"); + var loop = this.virtual_machine.event_loop_handle orelse @panic("EventLoop.enqueueTaskWithTimeout: uSockets event loop is not initialized"); var timer = uws.Timer.createFallthrough(loop, task.ptr()); timer.set(task.ptr(), callTask, timeout, 0); } @@ -911,9 +911,9 @@ pub const EventLoop = struct { pub fn ensureWaker(this: *EventLoop) void { JSC.markBinding(@src()); - if (this.virtual_machine.uws_event_loop == null) { + if (this.virtual_machine.event_loop_handle == null) { var actual = uws.Loop.get().?; - this.virtual_machine.uws_event_loop = actual; + this.virtual_machine.event_loop_handle = actual; this.virtual_machine.gc_controller.init(this.virtual_machine); // _ = actual.addPostHandler(*JSC.EventLoop, this, JSC.EventLoop.afterUSocketsTick); // _ = actual.addPreHandler(*JSC.VM, this.virtual_machine.global.vm(), JSC.VM.drainMicrotasks); @@ -926,7 +926,7 @@ pub const EventLoop = struct { } pub fn wakeup(this: *EventLoop) void { - if (this.virtual_machine.uws_event_loop) |loop| { + if (this.virtual_machine.event_loop_handle) |loop| { loop.wakeup(); } } diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index f1ef15b73..59b10a75a 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -401,7 +401,7 @@ pub const VirtualMachine = struct { origin: URL = URL{}, node_fs: ?*Node.NodeFS = null, timer: Bun.Timer = Bun.Timer{}, - uws_event_loop: ?*uws.Loop = null, + event_loop_handle: ?*uws.Loop = null, pending_unref_counter: i32 = 0, preload: []const string = &[_][]const u8{}, unhandled_pending_rejection_to_capture: ?*JSC.JSValue = null, @@ -724,7 +724,7 @@ pub const VirtualMachine = struct { pub fn prepareLoop(_: *VirtualMachine) void {} pub fn enterUWSLoop(this: *VirtualMachine) void { - var loop = this.uws_event_loop.?; + var loop = this.event_loop_handle.?; loop.run(); } @@ -732,7 +732,7 @@ pub const VirtualMachine = struct { this.exit_handler.dispatchOnBeforeExit(); var dispatch = false; while (true) { - while (this.eventLoop().tasks.count > 0 or this.active_tasks > 0 or this.uws_event_loop.?.active > 0) : (dispatch = true) { + while (this.eventLoop().tasks.count > 0 or this.active_tasks > 0 or this.event_loop_handle.?.active > 0) : (dispatch = true) { this.tick(); this.eventLoop().autoTickActive(); } @@ -741,7 +741,7 @@ pub const VirtualMachine = struct { this.exit_handler.dispatchOnBeforeExit(); dispatch = false; - if (this.eventLoop().tasks.count > 0 or this.active_tasks > 0 or this.uws_event_loop.?.active > 0) continue; + if (this.eventLoop().tasks.count > 0 or this.active_tasks > 0 or this.event_loop_handle.?.active > 0) continue; } break; @@ -884,7 +884,7 @@ pub const VirtualMachine = struct { this.eventLoop().tick(); while (true) { - while (this.eventLoop().tasks.count > 0 or this.active_tasks > 0 or this.uws_event_loop.?.active > 0) { + while (this.eventLoop().tasks.count > 0 or this.active_tasks > 0 or this.event_loop_handle.?.active > 0) { this.tick(); this.eventLoop().autoTickActive(); } diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index e52c9f0e2..3617d5961 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -146,7 +146,7 @@ pub const TestRunner = struct { this.pending_test = null; // disable idling - JSC.VirtualMachine.get().uws_event_loop.?.wakeup(); + JSC.VirtualMachine.get().event_loop_handle.?.wakeup(); } pub fn drain(this: *TestRunner) void { diff --git a/src/bun.js/web_worker.zig b/src/bun.js/web_worker.zig index 16d7aa34c..e9c9637b9 100644 --- a/src/bun.js/web_worker.zig +++ b/src/bun.js/web_worker.zig @@ -264,7 +264,7 @@ pub const WebWorker = struct { // don't run the GC if we don't actually need to if (vm.eventLoop().tasks.count > 0 or vm.active_tasks > 0 or - vm.uws_event_loop.?.active > 0 or + vm.event_loop_handle.?.active > 0 or vm.eventLoop().tickConcurrentWithCount() > 0) { vm.global.vm().releaseWeakRefs(); @@ -275,7 +275,7 @@ pub const WebWorker = struct { // always doing a first tick so we call CppTask without delay after dispatchOnline vm.tick(); - while (vm.eventLoop().tasks.count > 0 or vm.active_tasks > 0 or vm.uws_event_loop.?.active > 0) { + while (vm.eventLoop().tasks.count > 0 or vm.active_tasks > 0 or vm.event_loop_handle.?.active > 0) { vm.tick(); if (this.requested_terminate) break; vm.eventLoop().autoTickActive(); diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig index 85783dbc3..9688ef8ba 100644 --- a/src/bun.js/webcore/streams.zig +++ b/src/bun.js/webcore/streams.zig @@ -4809,7 +4809,7 @@ pub fn NewReadyWatcher( const fd = @as(c_int, @intCast(fd_)); std.debug.assert(@as(c_int, @intCast(this.poll_ref.?.fd)) == fd); std.debug.assert( - this.poll_ref.?.unregister(JSC.VirtualMachine.get().uws_event_loop.?) == .result, + this.poll_ref.?.unregister(JSC.VirtualMachine.get().event_loop_handle.?) == .result, ); } @@ -4848,7 +4848,7 @@ pub fn NewReadyWatcher( }; std.debug.assert(poll_ref.fd == fd); std.debug.assert(!this.isWatching()); - switch (poll_ref.register(JSC.VirtualMachine.get().uws_event_loop.?, flag, true)) { + switch (poll_ref.register(JSC.VirtualMachine.get().event_loop_handle.?, flag, true)) { .err => |err| { bun.unreachablePanic("FilePoll.register failed: {d}", .{err.errno}); }, diff --git a/src/bun_js.zig b/src/bun_js.zig index bb59d7e87..3578fb2ae 100644 --- a/src/bun_js.zig +++ b/src/bun_js.zig @@ -298,7 +298,7 @@ pub const Run = struct { // don't run the GC if we don't actually need to if (vm.eventLoop().tasks.count > 0 or vm.active_tasks > 0 or - vm.uws_event_loop.?.active > 0 or + vm.event_loop_handle.?.active > 0 or vm.eventLoop().tickConcurrentWithCount() > 0) { vm.global.vm().releaseWeakRefs(); @@ -315,7 +315,7 @@ pub const Run = struct { } while (true) { - while (vm.eventLoop().tasks.count > 0 or vm.active_tasks > 0 or vm.uws_event_loop.?.active > 0) { + while (vm.eventLoop().tasks.count > 0 or vm.active_tasks > 0 or vm.event_loop_handle.?.active > 0) { vm.tick(); // Report exceptions in hot-reloaded modules @@ -343,7 +343,7 @@ pub const Run = struct { vm.onUnhandledError(this.vm.global, this.vm.pending_internal_promise.result(vm.global.vm())); } } else { - while (vm.eventLoop().tasks.count > 0 or vm.active_tasks > 0 or vm.uws_event_loop.?.active > 0) { + while (vm.eventLoop().tasks.count > 0 or vm.active_tasks > 0 or vm.event_loop_handle.?.active > 0) { vm.tick(); vm.eventLoop().autoTickActive(); } diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig index 0af54f61b..4fce7759a 100644 --- a/src/cli/test_command.zig +++ b/src/cli/test_command.zig @@ -835,7 +835,7 @@ pub const TestCommand = struct { vm.eventLoop().tickPossiblyForever(); while (true) { - while (vm.eventLoop().tasks.count > 0 or vm.active_tasks > 0 or vm.uws_event_loop.?.active > 0) { + while (vm.eventLoop().tasks.count > 0 or vm.active_tasks > 0 or vm.event_loop_handle.?.active > 0) { vm.tick(); vm.eventLoop().autoTickActive(); } diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index c87baef3a..f275af0c6 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -197,12 +197,12 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { var loop = @as(*uws.Loop, @ptrCast(@alignCast(loop_))); var ctx: *uws.SocketContext = @as(*uws.SocketContext, @ptrCast(ctx_)); - if (vm.uws_event_loop) |other| { + if (vm.event_loop_handle) |other| { std.debug.assert(other == loop); } - const is_new_loop = vm.uws_event_loop == null; + const is_new_loop = vm.event_loop_handle == null; - vm.uws_event_loop = loop; + vm.event_loop_handle = loop; Socket.configure( ctx, @@ -236,7 +236,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { header_values: ?[*]const JSC.ZigString, header_count: usize, ) callconv(.C) ?*HTTPClient { - std.debug.assert(global.bunVM().uws_event_loop != null); + std.debug.assert(global.bunVM().event_loop_handle != null); var client_protocol_hash: u64 = 0; var body = buildRequestBody( @@ -881,11 +881,11 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { var ctx: *uws.SocketContext = @as(*uws.SocketContext, @ptrCast(ctx_)); - if (vm.uws_event_loop) |other| { + if (vm.event_loop_handle) |other| { std.debug.assert(other == loop); } - vm.uws_event_loop = loop; + vm.event_loop_handle = loop; Socket.configure( ctx, |