mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 13:51:47 +00:00
seems to work
This commit is contained in:
@@ -272,11 +272,11 @@ void Worker::terminate()
|
||||
// m_contextProxy.terminateWorkerGlobalScope();
|
||||
m_terminationFlags.fetch_or(TerminateRequestedFlag);
|
||||
|
||||
if (ScriptExecutionContext::getScriptExecutionContext(m_clientIdentifier)) {
|
||||
auto* impl = lifecycleHandle_;
|
||||
lifecycleHandle_ = nullptr;
|
||||
WebWorkerLifecycleHandle__requestTermination(impl);
|
||||
}
|
||||
// if (ScriptExecutionContext::getScriptExecutionContext(m_clientIdentifier)) {
|
||||
// auto* impl = lifecycleHandle_;
|
||||
// lifecycleHandle_ = nullptr;
|
||||
// WebWorkerLifecycleHandle__requestTermination(impl);
|
||||
// }
|
||||
}
|
||||
|
||||
// const char* Worker::activeDOMObjectName() const
|
||||
|
||||
@@ -448,6 +448,8 @@ fn unhandledError(this: *WebWorker, _: anyerror) void {
|
||||
}
|
||||
|
||||
pub export fn WebWorkerLifecycleHandle__requestTermination(handle: *WebWorkerLifecycleHandle) void {
|
||||
if (@intFromPtr(handle) == 0) return;
|
||||
|
||||
handle.requestTermination();
|
||||
}
|
||||
|
||||
@@ -700,24 +702,25 @@ const WebWorkerLifecycleHandle = struct {
|
||||
} else {
|
||||
self.mutex.unlock();
|
||||
self.deref();
|
||||
self.deinit();
|
||||
}
|
||||
|
||||
self.deref();
|
||||
}
|
||||
|
||||
pub fn onTermination(self: *WebWorkerLifecycleHandle) void {
|
||||
self.ref();
|
||||
self.mutex.lock();
|
||||
if (self.requested_terminate.swap(false, .acquire)) {
|
||||
// we already requested to terminate, therefore this handle has
|
||||
// already been consumed on the other thread and we are able to free
|
||||
// it.
|
||||
self.mutex.unlock();
|
||||
self.deinit();
|
||||
self.deref();
|
||||
return;
|
||||
}
|
||||
self.worker = null;
|
||||
self.mutex.unlock();
|
||||
self.deref();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user