mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 23:01:44 +01:00
PendingQuestion: removed unnecessary finalizer
This commit is contained in:
parent
ac50b7454a
commit
01513ef71f
@ -49,13 +49,7 @@ namespace Capnp.Rpc
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Question object was disposed.
|
/// Question object was disposed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Disposed = 16,
|
Disposed = 16
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Question object was finalized by GC.
|
|
||||||
/// This flag should only be observable when debugging the finalizer itself.
|
|
||||||
/// </summary>
|
|
||||||
Finalized = 32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly TaskCompletionSource<DeserializerState> _tcs = new TaskCompletionSource<DeserializerState>();
|
readonly TaskCompletionSource<DeserializerState> _tcs = new TaskCompletionSource<DeserializerState>();
|
||||||
@ -76,7 +70,7 @@ namespace Capnp.Rpc
|
|||||||
{
|
{
|
||||||
foreach (var cap in inParams.Caps!)
|
foreach (var cap in inParams.Caps!)
|
||||||
{
|
{
|
||||||
cap?.AddRef();
|
cap.AddRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +273,7 @@ namespace Capnp.Rpc
|
|||||||
{
|
{
|
||||||
foreach (var cap in inParams.Caps!)
|
foreach (var cap in inParams.Caps!)
|
||||||
{
|
{
|
||||||
cap?.Release();
|
cap.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +287,7 @@ namespace Capnp.Rpc
|
|||||||
{
|
{
|
||||||
foreach (var cap in outParams.Caps!)
|
foreach (var cap in outParams.Caps!)
|
||||||
{
|
{
|
||||||
cap?.Release();
|
cap.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,54 +326,7 @@ namespace Capnp.Rpc
|
|||||||
OnException(exception);
|
OnException(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseCaps(target!, inParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IDisposable Support
|
|
||||||
|
|
||||||
void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
SerializerState? inParams;
|
|
||||||
ConsumedCapability? target;
|
|
||||||
bool justDisposed = false;
|
|
||||||
|
|
||||||
lock (ReentrancyBlocker)
|
|
||||||
{
|
|
||||||
inParams = _inParams;
|
|
||||||
_inParams = null;
|
|
||||||
target = _target;
|
|
||||||
_target = null;
|
|
||||||
|
|
||||||
if (disposing)
|
|
||||||
{
|
|
||||||
if (!StateFlags.HasFlag(State.Disposed))
|
|
||||||
{
|
|
||||||
StateFlags |= State.Disposed;
|
|
||||||
justDisposed = true;
|
|
||||||
|
|
||||||
AutoFinish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StateFlags |= State.Finalized;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ReleaseCaps(target, inParams);
|
ReleaseCaps(target, inParams);
|
||||||
|
|
||||||
if (justDisposed)
|
|
||||||
{
|
|
||||||
_tcs.TrySetCanceled();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Finalizer
|
|
||||||
/// </summary>
|
|
||||||
~PendingQuestion()
|
|
||||||
{
|
|
||||||
Dispose(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -387,9 +334,23 @@ namespace Capnp.Rpc
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
bool justDisposed = false;
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
|
lock (ReentrancyBlocker)
|
||||||
|
{
|
||||||
|
if (!StateFlags.HasFlag(State.Disposed))
|
||||||
|
{
|
||||||
|
StateFlags |= State.Disposed;
|
||||||
|
justDisposed = true;
|
||||||
|
|
||||||
|
AutoFinish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (justDisposed)
|
||||||
|
{
|
||||||
|
_tcs.TrySetCanceled();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user