aspnetcore/src/Microsoft.AspNet.Server.Kes.../Networking/UvRequest.cs

34 lines
698 B
C#

using System;
using System.Runtime.InteropServices;
using Microsoft.AspNet.Server.Kestrel.Infrastructure;
namespace Microsoft.AspNet.Server.Kestrel.Networking
{
public class UvRequest : UvMemory
{
private GCHandle _pin;
protected UvRequest(IKestrelTrace logger) : base (logger)
{
}
protected override bool ReleaseHandle()
{
DestroyMemory(handle);
handle = IntPtr.Zero;
return true;
}
public virtual void Pin()
{
_pin = GCHandle.Alloc(this, GCHandleType.Normal);
}
public virtual void Unpin()
{
_pin.Free();
}
}
}