Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
GILState.Dispose is safe to be called multiple times
  • Loading branch information
lostmsu committed Feb 1, 2020
commit fcbee0a3011d399d5cf5600cdd8ec76fa5db6922
6 changes: 5 additions & 1 deletion src/runtime/pythonengine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,8 @@ public static PyScope CreateScope(string name)

public class GILState : IDisposable
{
private IntPtr state;
private readonly IntPtr state;
private bool isDisposed;

internal GILState()
{
Expand All @@ -652,8 +653,11 @@ internal GILState()

public void Dispose()
{
if (this.isDisposed) return;

PythonEngine.ReleaseLock(state);
GC.SuppressFinalize(this);
this.isDisposed = true;
}

~GILState()
Expand Down