Navigation
API > API/Runtime > API/Runtime/Core
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.
| Name | FBufferOwner |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Memory/SharedBuffer.h |
| Include Path | #include "Memory/SharedBuffer.h" |
Syntax
class FBufferOwner
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FBufferOwner
(
void* InData, |
Memory/SharedBuffer.h | ||
FBufferOwner
(
const FBufferOwner& |
Memory/SharedBuffer.h | ||
FBufferOwner () |
Memory/SharedBuffer.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual ~FBufferOwner() |
Memory/SharedBuffer.h |
Enums
Public
| Name | Remarks |
|---|---|
| EBufferOwnerFlags |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| RefCountMask | uint32 | Memory/SharedBuffer.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Data | void * | Memory/SharedBuffer.h | ||
| ReferenceCountsAndFlags | std::atomic< uint64 > | Memory/SharedBuffer.h | ||
| Size | uint64 | Memory/SharedBuffer.h |
Functions
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void FreeBuffer () |
Free the buffer and any associated resources. | Memory/SharedBuffer.h | |
void * GetData() |
Memory/SharedBuffer.h | ||
uint64 GetSize() |
Memory/SharedBuffer.h | ||
uint32 GetTotalRefCount () |
Memory/SharedBuffer.h | ||
bool IsImmutable() |
Memory/SharedBuffer.h | ||
bool IsMaterialized() |
Memory/SharedBuffer.h | ||
bool IsOwned() |
Memory/SharedBuffer.h | ||
void Materialize() |
Memory/SharedBuffer.h | ||
virtual void MaterializeBuffer () |
Materialize the buffer by making it ready to be accessed. | Memory/SharedBuffer.h | |
void SetBuffer
(
void* InData, |
Memory/SharedBuffer.h | ||
void SetIsImmutable() |
Memory/SharedBuffer.h | ||
void SetIsMaterialized() |
Memory/SharedBuffer.h | ||
void SetIsOwned() |
Memory/SharedBuffer.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static EBufferOwnerFlags GetFlags
(
uint64 RefCountsAndFlags |
Memory/SharedBuffer.h | ||
static uint32 GetSharedRefCount
(
uint64 RefCountsAndFlags |
Memory/SharedBuffer.h | ||
static uint32 GetTotalRefCount
(
uint64 RefCountsAndFlags |
Memory/SharedBuffer.h | ||
static uint32 GetWeakRefCount
(
uint64 RefCountsAndFlags |
Memory/SharedBuffer.h | ||
static uint64 SetFlags
(
EBufferOwnerFlags Flags |
Memory/SharedBuffer.h | ||
static uint64 SetSharedRefCount
(
uint32 RefCount |
Memory/SharedBuffer.h | ||
static uint64 SetWeakRefCount
(
uint32 RefCount |
Memory/SharedBuffer.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FBufferOwner & operator=
(
const FBufferOwner& |
Memory/SharedBuffer.h |