FBufferOwner

A reference-counted owner for a buffer, which is a raw pointer and size.

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Memory/SharedBuffer.h

Include

#include "Memory/SharedBuffer.h"

Syntax

class FBufferOwner

Remarks

A reference-counted owner for a buffer, which is a raw pointer and size.

A buffer owner may own its memory or provide a view into memory owned externally. When used as a non-owning view, the viewed memory must be guaranteed to outlive the buffer owner. When this lifetime guarantee cannot be satisfied, MakeOwned may be called on the reference to the buffer to clone into a new buffer owner that owns the memory.

A buffer owner must be referenced and accessed through one of its three reference types: FUniqueBuffer, FSharedBuffer, or FWeakSharedBuffer.

FUniqueBuffer and FSharedBuffer offer static functions to create a buffer using private buffer owner types that are ideal for most use cases. The TakeOwnership function allows creation of a buffer with a custom delete function. Advanced use cases require deriving from FBufferOwner to enable storage of arbitrary members alongside the data and size, and to enable materialization of the buffer to be deferred.

A derived type must call SetIsOwned from its constructor if they own (or will own) the buffer. A derived type must call SetIsImmutable from its constructor if they want the buffer to become permanently immutable after it is stored in FSharedBuffer, forcing MoveToUnique() to clone it. A derived type must call SetIsMaterialized from its constructor, unless it implements deferred materialization by overriding MaterializeBuffer.

Constructors

Name Description

Protected function

FBufferOwner()

Protected function

FBufferOwner

(
    const FBufferOwner&
)

Protected function

FBufferOwner

(
    void* InData,
    uint64 InSize
)

Destructors

Name Description

Protected function Virtual

~FBufferOwner()

Functions

Name Description

Protected function

void

 

FreeBuffer()

Free the buffer and any associated resources.

Protected function

void *

 

GetData()

Protected function

uint64

 

GetSize()

Protected function Const

uint32

 

GetTotalRefCount()

Protected function Const

bool

 

IsImmutable()

Protected function Const

bool

 

IsMaterialized()

Protected function Const

bool

 

IsOwned()

Protected function

void

 

Materialize()

Protected function Virtual

void

 

MaterializeBuffer()

Materialize the buffer by making it ready to be accessed.

Protected function

void

 

SetBuffer

(
    void* InData,
    uint64 InSize
)

Protected function

void

 

SetIsImmutable()

Protected function

void

 

SetIsMaterialized()

Protected function

void

 

SetIsOwned()

Operators

Name Description

Protected function

FBufferOwner...

 

operator=

(
    const FBufferOwner&
)

Enums

Name

Description

Public enum

EBufferOwnerFlags

Constants

Name

Description

RefCountMask