mirror of
https://github.com/oven-sh/bun
synced 2026-02-17 14:22:01 +00:00
rm
This commit is contained in:
@@ -78,9 +78,6 @@ export fn WebWorker__updatePtr(worker: *WebWorker, ptr: *anyopaque) bool {
|
||||
startWithErrorHandling,
|
||||
.{worker},
|
||||
) catch {
|
||||
log("[{d}] WebWorker__updatePtr - failed to spawn thread, dispatching exit", .{worker.execution_context_id});
|
||||
worker.setStatus(.terminated);
|
||||
WebWorker__dispatchExit(null, worker.cpp_worker, 1);
|
||||
worker.deinit();
|
||||
return false;
|
||||
};
|
||||
@@ -444,13 +441,6 @@ fn spin(this: *WebWorker) void {
|
||||
log("[{d}] spin start", .{this.execution_context_id});
|
||||
|
||||
var vm = this.vm.?;
|
||||
|
||||
// did we terminate before even starting ?
|
||||
if (this.hasRequestedTerminate() or this.status.load(.acquire) == .terminated) {
|
||||
log("[{d}] spin - terminated before start", .{this.execution_context_id});
|
||||
return;
|
||||
}
|
||||
|
||||
assert(this.status.load(.acquire) == .start);
|
||||
this.setStatus(.starting);
|
||||
vm.preload = this.preloads;
|
||||
@@ -570,30 +560,6 @@ pub fn notifyNeedTermination(this: *WebWorker) callconv(.c) void {
|
||||
}
|
||||
log("[{d}] notifyNeedTermination", .{this.execution_context_id});
|
||||
|
||||
const current_status = this.status.load(.acquire);
|
||||
|
||||
// If the worker hasn't started yet or is still starting, we need to handle termination differently
|
||||
// This can happen when:
|
||||
// 1. terminate() is called immediately after creating the worker
|
||||
// 2. The worker thread hasn't been spawned yet
|
||||
// 3. The worker thread is spawned but hasn't reached the event loop
|
||||
// In these cases, we need to dispatch the exit event immediately because the worker
|
||||
// thread might not be able to do it itself.
|
||||
if (current_status == .start or current_status == .starting) {
|
||||
log("[{d}] notifyNeedTermination - worker not fully started, dispatching exit immediately", .{this.execution_context_id});
|
||||
|
||||
this.setStatus(.terminated);
|
||||
|
||||
// Dispatch the exit event immediately since the worker thread might not be running yet
|
||||
// or might not have reached the event loop
|
||||
WebWorker__dispatchExit(null, this.cpp_worker, 0);
|
||||
this.parent_poll_ref.unrefConcurrently(this.parent);
|
||||
|
||||
if (this.vm) |vm| vm.eventLoop().wakeup();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.vm) |vm| {
|
||||
vm.eventLoop().wakeup();
|
||||
// TODO(@190n) notifyNeedTermination
|
||||
|
||||
Reference in New Issue
Block a user