Skip to content

Commit

Permalink
Add some more threading API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
tonybaloney committed Aug 12, 2024
1 parent a9f23e6 commit 609b79b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/CSnakes.Runtime/CPython/GIL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,18 @@ internal unsafe partial class CPythonAPI
/// <returns>1 if held, 0 if not.</returns>
[LibraryImport(PythonLibraryName)]
internal static partial int PyGILState_Check();

internal static int GetNativeThreadId()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
return GetCurrentThreadId();
else
return -1;
}

[LibraryImport("kernel32.dll")]
private static partial int GetCurrentThreadId();

[LibraryImport(PythonLibraryName)]
internal static partial int Py_MakePendingCalls();
}

0 comments on commit 609b79b

Please sign in to comment.