Skip to content

Commit 8f23379

Browse files
committed
Add a more general getter for JS interop to keep a webworker alive
And link to dotnet#85052 for more details
1 parent fb3f7ab commit 8f23379

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/mono/System.Private.CoreLib/src/System/Threading/WebWorkerEventLoop.Browser.Threads.Mono.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,21 @@ internal static void StartExitable(Thread thread, bool captureContext)
7575
}
7676

7777
/// returns true if the current thread has unsettled JS Interop promises
78-
internal static bool HasUnsettledInteropPromises => HasUnsettledInteropPromisesNative();
78+
private static bool HasUnsettledInteropPromises => HasUnsettledInteropPromisesNative();
7979

8080
// FIXME: this could be a qcall with a SuppressGCTransitionAttribute
8181
[MethodImpl(MethodImplOptions.InternalCall)]
8282
private static extern bool HasUnsettledInteropPromisesNative();
83+
84+
/// <summary>returns true if the current WebWorker has JavaScript objects that depend on the
85+
/// current managed thread.</summary>
86+
//
87+
/// <remarks>If this returns false, the runtime is allowed to allow the current managed thread
88+
/// to exit and for the WebWorker to be recycled by Emscripten for another managed
89+
/// thread.</remarks>
90+
//
91+
// FIXME:
92+
// https://github.com/dotnet/runtime/issues/85052 - unsettled promises are not the only relevant
93+
// reasons for keeping a worker thread alive. We will need to add other conditions here.
94+
internal static bool HasJavaScriptInteropDependents => HasUnsettledInteropPromises;
8395
}

0 commit comments

Comments
 (0)