Skip to content

Commit

Permalink
Add a more general getter for JS interop to keep a webworker alive
Browse files Browse the repository at this point in the history
And link to #85052 for more details
  • Loading branch information
lambdageek committed Apr 19, 2023
1 parent fb3f7ab commit 8f23379
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,21 @@ internal static void StartExitable(Thread thread, bool captureContext)
}

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

// FIXME: this could be a qcall with a SuppressGCTransitionAttribute
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool HasUnsettledInteropPromisesNative();

/// <summary>returns true if the current WebWorker has JavaScript objects that depend on the
/// current managed thread.</summary>
//
/// <remarks>If this returns false, the runtime is allowed to allow the current managed thread
/// to exit and for the WebWorker to be recycled by Emscripten for another managed
/// thread.</remarks>
//
// FIXME:
// https://github.com/dotnet/runtime/issues/85052 - unsettled promises are not the only relevant
// reasons for keeping a worker thread alive. We will need to add other conditions here.
internal static bool HasJavaScriptInteropDependents => HasUnsettledInteropPromises;
}

0 comments on commit 8f23379

Please sign in to comment.