For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo struct
AnyAsyncValueRef
struct AnyAsyncValueRef
Owning, reference-counted handle to a C++ AsyncValue -- a limited Mojo counterpart of the C++ AnyAsyncValueRef / RCRef[AsyncValue].
Holds a pointer to the AsyncValue; copying retains (adds one reference) and
destruction releases one. A null handle is the empty / non-tracked reference.
Used as the storage handle of an OwnedByteBuffer, mirroring the storageRef
field of the C++ TensorBufferRef.
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDeletable,
Movable
Methodsβ
__init__β
def __init__(out self)
Creates an empty (null) AsyncValue reference.
def __init__(out self, handle: Optional[Pointer[_AsyncValueCpp, MutUntrackedOrigin, _safe=False]])
Adopts an already-owning handle net-zero (does not retain).
Args:
- βhandle (
Optional[Pointer[_AsyncValueCpp, MutUntrackedOrigin, _safe=False]]): AnAsyncValue*whose single live reference is transferred to this wrapper.
def __init__(out self, *, copy: Self)
Creates a new owning reference by retaining the shared AsyncValue.
Args:
- βcopy (
Self): The reference to copy.
def __init__(out self, *, retained_storage_of: Pointer[NoneType, MutAnyOrigin, _safe=True])
Retains the backing storage of a packed async slot into a new ref.
Reads the AsyncValue* behind the slot's TensorBufferRef storage
handle and adds one reference, so the returned handle independently keeps
the backing memory alive (e.g. when an unpacked value is re-packed).
Args:
- βretained_storage_of (
Pointer[NoneType, MutAnyOrigin, _safe=True]): A pointer to the packed async value (slot) whose backing storage should be retained.
def __init__(out self, *, retain_handle: Pointer[NoneType, MutAnyOrigin, _safe=True])
Retains an existing AnyAsyncValueRef storage handle into a new ref.
Reads the AsyncValue* behind the given C++ AnyAsyncValueRef handle
(e.g. a cached buffer's memory handle) and adds one reference. A null
handle yields the empty (non-tracked) reference.
Args:
- βretain_handle (
Pointer[NoneType, MutAnyOrigin, _safe=True]): A pointer to a C++AnyAsyncValueRefstorage handle.
def __init__(out self, *, var storage_buf: DeviceBuffer)
Wraps a live owning DeviceBuffer in an AsyncValue[DeviceBufferRef].
The buffer's handle is surrendered net-zero (take_handle) and adopted
by the runtime, so no extra reference is created.
Args:
- βstorage_buf (
DeviceBuffer): The owning device buffer to wrap.
__del__β
def __del__(deinit self)
Releases this reference to the underlying AsyncValue.
take_handleβ
def take_handle(deinit self) -> Optional[Pointer[_AsyncValueCpp, MutUntrackedOrigin, _safe=False]]
Surrenders the owning handle net-zero, suppressing the destructor.
Returns:
Optional[Pointer[_AsyncValueCpp, MutUntrackedOrigin, _safe=False]]: The owning AsyncValue*; the caller must hand it to a runtime owner
that adopts it without an extra reference.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!