mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
addressing some pr feedback
This commit is contained in:
@@ -369,34 +369,34 @@ ScriptExecutionContext* executionContext(JSC::JSGlobalObject* globalObject)
|
||||
void ScriptExecutionContext::postTaskConcurrently(Function<void(ScriptExecutionContext&)>&& lambda)
|
||||
{
|
||||
auto* task = new EventLoopTask(WTFMove(lambda));
|
||||
reinterpret_cast<Zig::GlobalObject*>(m_globalObject)->queueTaskConcurrently(task);
|
||||
static_cast<Zig::GlobalObject*>(m_globalObject)->queueTaskConcurrently(task);
|
||||
}
|
||||
// Executes the task on context's thread asynchronously.
|
||||
void ScriptExecutionContext::postTask(Function<void(ScriptExecutionContext&)>&& lambda)
|
||||
{
|
||||
auto* task = new EventLoopTask(WTFMove(lambda));
|
||||
reinterpret_cast<Zig::GlobalObject*>(m_globalObject)->queueTask(task);
|
||||
static_cast<Zig::GlobalObject*>(m_globalObject)->queueTask(task);
|
||||
}
|
||||
// Executes the task on context's thread asynchronously.
|
||||
void ScriptExecutionContext::postTask(EventLoopTask* task)
|
||||
{
|
||||
reinterpret_cast<Zig::GlobalObject*>(m_globalObject)->queueTask(task);
|
||||
static_cast<Zig::GlobalObject*>(m_globalObject)->queueTask(task);
|
||||
}
|
||||
// Executes the task on context's thread immediately.
|
||||
void ScriptExecutionContext::postImmediateCppTask(Function<void(ScriptExecutionContext&)>&& lambda)
|
||||
{
|
||||
auto* task = new EventLoopTask(WTFMove(lambda));
|
||||
reinterpret_cast<Zig::GlobalObject*>(m_globalObject)->queueImmediateCppTask(task);
|
||||
static_cast<Zig::GlobalObject*>(m_globalObject)->queueImmediateCppTask(task);
|
||||
}
|
||||
// Executes the task on context's thread immediately.
|
||||
void ScriptExecutionContext::postImmediateCppTask(EventLoopTask* task)
|
||||
{
|
||||
reinterpret_cast<Zig::GlobalObject*>(m_globalObject)->queueImmediateCppTask(task);
|
||||
static_cast<Zig::GlobalObject*>(m_globalObject)->queueImmediateCppTask(task);
|
||||
}
|
||||
// Executes the task on context's thread asynchronously.
|
||||
void ScriptExecutionContext::postTaskOnTimeout(EventLoopTask* task, Seconds timeout)
|
||||
{
|
||||
reinterpret_cast<Zig::GlobalObject*>(m_globalObject)->queueTaskOnTimeout(task, static_cast<int>(timeout.milliseconds()));
|
||||
static_cast<Zig::GlobalObject*>(m_globalObject)->queueTaskOnTimeout(task, static_cast<int>(timeout.milliseconds()));
|
||||
}
|
||||
// Executes the task on context's thread asynchronously.
|
||||
void ScriptExecutionContext::postTaskOnTimeout(Function<void(ScriptExecutionContext&)>&& lambda, Seconds timeout)
|
||||
|
||||
@@ -313,7 +313,7 @@ void MessagePort::dispatchMessages()
|
||||
auto messagesTakenHandler = [this, protectedThis = Ref { *this }](Vector<MessageWithMessagePorts>&& messages, CompletionHandler<void()>&& completionCallback) mutable {
|
||||
RefPtr<ScriptExecutionContext> context = scriptExecutionContext();
|
||||
if (!context || !context->globalObject()) {
|
||||
WTFMove(completionCallback)();
|
||||
completionCallback();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,16 @@ const DrainMicrotasksResult = enum(u8) {
|
||||
extern fn JSC__JSGlobalObject__drainMicrotasks(*jsc.JSGlobalObject) DrainMicrotasksResult;
|
||||
pub fn drainMicrotasksWithGlobal(this: *EventLoop, globalObject: *jsc.JSGlobalObject, jsc_vm: *jsc.VM) bun.JSExecutionTerminated!void {
|
||||
jsc.markBinding(@src());
|
||||
|
||||
// this exists because while we're inside a spawnSync call, some tasks can actually
|
||||
// still complete which leads to a case where module resolution can partially complete and
|
||||
// some modules are only partially evaluated which causes reference errors.
|
||||
// TODO: A better fix here could be a second event loop so we can come off the main one
|
||||
// while processing spawnSync, then resume back to here afterwards
|
||||
if (this.is_inside_spawn_sync) {
|
||||
return;
|
||||
}
|
||||
|
||||
jsc_vm.releaseWeakRefs();
|
||||
|
||||
switch (JSC__JSGlobalObject__drainMicrotasks(globalObject)) {
|
||||
|
||||
Reference in New Issue
Block a user