mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
remove immediate cpp task
This commit is contained in:
@@ -185,7 +185,7 @@ ExceptionOr<void> MessagePort::postMessage(JSC::JSGlobalObject& state, JSC::JSVa
|
||||
|
||||
auto* context = scriptExecutionContext();
|
||||
if (!context->canSendMessage()) {
|
||||
context->postImmediateCppTask([protectedThis = Ref { *this }, message = WTFMove(message)](ScriptExecutionContext& ctx) mutable {
|
||||
context->postTask([protectedThis = Ref { *this }, message = WTFMove(message)](ScriptExecutionContext& ctx) mutable {
|
||||
if (protectedThis->isEntangled()) {
|
||||
MessagePortChannelProvider::fromContext(ctx).postMessageToRemote(WTFMove(message), protectedThis->m_remoteIdentifier);
|
||||
}
|
||||
@@ -289,7 +289,7 @@ void MessagePort::processMessages(ScriptExecutionContext& context, Vector<Messag
|
||||
|
||||
if (!deferredMessages.isEmpty()) {
|
||||
// remaining messages should happen on da next tick
|
||||
context.postImmediateCppTask(
|
||||
context.postTask(
|
||||
[protectedThis = Ref { *this }, deferred = WTFMove(deferredMessages), completionCallback = WTFMove(completionCallback)](ScriptExecutionContext& ctx) mutable {
|
||||
RefPtr<ScriptExecutionContext> contextPtr = protectedThis->scriptExecutionContext();
|
||||
if (!contextPtr || contextPtr->activeDOMObjectsAreSuspended() || !protectedThis->isEntangled()) {
|
||||
|
||||
@@ -479,7 +479,6 @@ pub fn tick(this: *EventLoop) void {
|
||||
while (true) {
|
||||
while (this.tickWithCount(ctx) > 0) : (this.global.handleRejectedPromises()) {
|
||||
this.tickConcurrent();
|
||||
this.tickImmediateTasks(ctx);
|
||||
} else {
|
||||
this.drainMicrotasksWithGlobal(global, global_vm) catch return;
|
||||
if (scope.hasException()) return;
|
||||
|
||||
@@ -2,7 +2,7 @@ import assert from "node:assert";
|
||||
import { test } from "node:test";
|
||||
import { MessageChannel, receiveMessageOnPort, Worker } from "worker_threads";
|
||||
|
||||
test("MessagePort postMessage uses immediate C++ tasks correctly", async () => {
|
||||
test("MessagePort postMessage respects event loop timing", async () => {
|
||||
const { port1, port2 } = new MessageChannel();
|
||||
|
||||
const messages: string[] = [];
|
||||
@@ -90,7 +90,7 @@ test("MessagePort messages execute after process.nextTick (Node.js compatibility
|
||||
port2.close();
|
||||
});
|
||||
|
||||
test("MessagePort immediate C++ tasks work with workers", async () => {
|
||||
test("MessagePort message delivery works with workers", async () => {
|
||||
const worker = new Worker(
|
||||
`
|
||||
const { parentPort, MessageChannel } = require('worker_threads');
|
||||
@@ -169,7 +169,7 @@ test("MessagePort immediate C++ tasks work with workers", async () => {
|
||||
worker.terminate();
|
||||
});
|
||||
|
||||
test("immediate C++ tasks don't starve microtasks", async () => {
|
||||
test("MessagePort messages don't starve microtasks", async () => {
|
||||
const { port1, port2 } = new MessageChannel();
|
||||
|
||||
const executionOrder: string[] = [];
|
||||
@@ -252,7 +252,7 @@ test("high volume MessagePort operations maintain order", async () => {
|
||||
port2.close();
|
||||
});
|
||||
|
||||
test("MessagePort close behavior with immediate C++ tasks", async () => {
|
||||
test("MessagePort close behavior during message handling", async () => {
|
||||
const { port1, port2 } = new MessageChannel();
|
||||
|
||||
let messageReceived = false;
|
||||
@@ -286,7 +286,7 @@ test("MessagePort close behavior with immediate C++ tasks", async () => {
|
||||
port1.close();
|
||||
});
|
||||
|
||||
test("receiveMessageOnPort works with immediate C++ tasks", () => {
|
||||
test("receiveMessageOnPort synchronous message retrieval", () => {
|
||||
const { port1, port2 } = new MessageChannel();
|
||||
|
||||
port1.postMessage("msg1");
|
||||
|
||||
Reference in New Issue
Block a user