diff options
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Buffers/IPinnable.cs')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Buffers/IPinnable.cs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Buffers/IPinnable.cs b/src/System.Private.CoreLib/shared/System/Buffers/IPinnable.cs new file mode 100644 index 000000000..623e716a0 --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Buffers/IPinnable.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Buffers +{ + /// <summary> + /// Provides a mechanism for pinning and unpinning objects to prevent the GC from moving them. + /// </summary> + public interface IPinnable + { + /// <summary> + /// Call this method to indicate that the IPinnable object can not be moved by the garbage collector. + /// The address of the pinned object can be taken. + /// <param name="elementIndex">The offset to the element within the memory at which the returned <see cref="MemoryHandle"/> points to.</param> + /// </summary> + MemoryHandle Pin(int elementIndex); + + /// <summary> + /// Call this method to indicate that the IPinnable object no longer needs to be pinned. + /// The garbage collector is free to move the object now. + /// </summary> + void Unpin(); + } +} |