mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 11:59:00 +00:00
Revert "Experiment: keep flushing immediate queue"
This reverts commit cd5c6693b5.
This commit is contained in:
@@ -1359,9 +1359,8 @@ pub const EventLoop = struct {
|
||||
var ctx = this.virtual_machine;
|
||||
var loop = this.usocketsLoop();
|
||||
|
||||
while (this.flushImmediateQueue()) {
|
||||
this.tickImmediateTasks(ctx);
|
||||
}
|
||||
this.flushImmediateQueue();
|
||||
this.tickImmediateTasks(ctx);
|
||||
|
||||
if (comptime Environment.isPosix) {
|
||||
// Some tasks need to keep the event loop alive for one more tick.
|
||||
@@ -1398,28 +1397,22 @@ pub const EventLoop = struct {
|
||||
ctx.timer.drainTimers(ctx);
|
||||
}
|
||||
|
||||
while (this.flushImmediateQueue()) {
|
||||
this.tickImmediateTasks(ctx);
|
||||
}
|
||||
|
||||
this.flushImmediateQueue();
|
||||
ctx.onAfterEventLoop();
|
||||
}
|
||||
|
||||
pub fn flushImmediateQueue(this: *EventLoop) bool {
|
||||
pub fn flushImmediateQueue(this: *EventLoop) void {
|
||||
// If we can get away with swapping the queues, do that rather than copying the data
|
||||
if (this.immediate_tasks.count > 0) {
|
||||
this.immediate_tasks.write(this.next_immediate_tasks.readableSlice(0)) catch unreachable;
|
||||
this.next_immediate_tasks.head = 0;
|
||||
this.next_immediate_tasks.count = 0;
|
||||
return true;
|
||||
} else if (this.next_immediate_tasks.count > 0) {
|
||||
const prev_immediate = this.immediate_tasks;
|
||||
const next_immediate = this.next_immediate_tasks;
|
||||
this.immediate_tasks = next_immediate;
|
||||
this.next_immediate_tasks = prev_immediate;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
pub fn tickPossiblyForever(this: *EventLoop) void {
|
||||
@@ -1457,9 +1450,8 @@ pub const EventLoop = struct {
|
||||
pub fn autoTickActive(this: *EventLoop) void {
|
||||
var loop = this.usocketsLoop();
|
||||
var ctx = this.virtual_machine;
|
||||
while (this.flushImmediateQueue()) {
|
||||
this.tickImmediateTasks(ctx);
|
||||
}
|
||||
this.flushImmediateQueue();
|
||||
this.tickImmediateTasks(ctx);
|
||||
|
||||
if (comptime Environment.isPosix) {
|
||||
const pending_unref = ctx.pending_unref_counter;
|
||||
@@ -1482,9 +1474,7 @@ pub const EventLoop = struct {
|
||||
ctx.timer.drainTimers(ctx);
|
||||
}
|
||||
|
||||
while (this.flushImmediateQueue()) {
|
||||
this.tickImmediateTasks(ctx);
|
||||
}
|
||||
this.flushImmediateQueue();
|
||||
ctx.onAfterEventLoop();
|
||||
}
|
||||
|
||||
|
||||
@@ -1244,7 +1244,7 @@ pub const TestCommand = struct {
|
||||
vm.eventLoop().tick();
|
||||
|
||||
var prev_unhandled_count = vm.unhandled_error_counter;
|
||||
while (vm.active_tasks > 0) : (_ = vm.eventLoop().flushImmediateQueue()) {
|
||||
while (vm.active_tasks > 0) : (vm.eventLoop().flushImmediateQueue()) {
|
||||
if (!jest.Jest.runner.?.has_pending_tests) {
|
||||
jest.Jest.runner.?.drain();
|
||||
}
|
||||
@@ -1264,9 +1264,7 @@ pub const TestCommand = struct {
|
||||
}
|
||||
}
|
||||
|
||||
while (vm.eventLoop().flushImmediateQueue()) {
|
||||
vm.eventLoop().tickImmediateTasks(vm);
|
||||
}
|
||||
vm.eventLoop().flushImmediateQueue();
|
||||
|
||||
switch (vm.aggressive_garbage_collection) {
|
||||
.none => {},
|
||||
|
||||
Reference in New Issue
Block a user