mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 05:42:43 +00:00
Merge branch 'ali/piscina' of github.com:oven-sh/bun into ali/piscina
This commit is contained in:
@@ -690,9 +690,18 @@ const WebWorkerLifecycleHandle = struct {
|
||||
}
|
||||
|
||||
pub fn requestTermination(self: *WebWorkerLifecycleHandle) void {
|
||||
if (self.requested_terminate.load(.acquire)) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.ref();
|
||||
self.mutex.lock();
|
||||
self.requested_terminate.store(true, .monotonic);
|
||||
|
||||
if (self.requested_terminate.swap(true, .monotonic)) {
|
||||
self.mutex.unlock();
|
||||
self.deref();
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.worker) |worker| {
|
||||
self.worker = null;
|
||||
@@ -701,6 +710,7 @@ const WebWorkerLifecycleHandle = struct {
|
||||
worker.deref();
|
||||
} else {
|
||||
self.mutex.unlock();
|
||||
// Let the reference counting system handle deinitialization
|
||||
self.deref();
|
||||
}
|
||||
|
||||
@@ -713,7 +723,7 @@ const WebWorkerLifecycleHandle = struct {
|
||||
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.
|
||||
// it. Let the reference counting system handle deinitialization.
|
||||
self.mutex.unlock();
|
||||
self.deref();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user