IMemoryOwner<T> 介面

定義

識別記憶體區塊的擁有者,該擁有者負責妥善地處置基礎記憶體。

generic <typename T>
public interface class IMemoryOwner : IDisposable
public interface IMemoryOwner<T> : IDisposable
type IMemoryOwner<'T> = interface
    interface IDisposable
Public Interface IMemoryOwner(Of T)
Implements IDisposable

類型參數

T

要儲存在記憶體中的專案類型。

衍生
實作

備註

介面 IMemoryOwner<T> 可用來定義負責管理緩衝區存留期的 Memory<T> 擁有者。 方法會傳 MemoryPool<T>.Rent 回 介面的 IMemoryOwner<T> 實例。

雖然緩衝區可以有多個取用者,但在任何指定時間只能有單一擁有者。 擁有者可以:

  • 直接建立緩衝區,或呼叫 Factory 方法。

  • 將擁有權轉移給另一個取用者。 在此情況下,先前的擁有者不應該再使用緩衝區。

  • 當緩衝區不再使用時,請終結緩衝區。

IMemoryOwner<T>因為 物件會實作 IDisposable 介面,所以只有在不再需要記憶體緩衝區且已終結它之後,才應該呼叫其 Dispose 方法。 當物件的參考可供使用時, IMemoryOwner<T>不應該處置物件。 這表示宣告所在的 IMemoryOwner<T> 型別不應該有 Finalize 方法。

屬性

Memory

取得屬於此擁有者的記憶體。

方法

Dispose()

執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。

(繼承來源 IDisposable)

適用於