Struct JHandle<T>
Handle for an unmanaged object stored in a PartitionedBuffer<T>. The handle remains stable even when the underlying memory is resized.
public readonly struct JHandle<T> : IEquatable<JHandle<T>> where T : unmanaged
Type Parameters
TThe unmanaged type of the data.
- Implements
-
IEquatable<JHandle<T>>
- Inherited Members
Remarks
Validity: A handle is valid only while the owning PartitionedBuffer<T> exists and the element has not been freed via Free(JHandle<T>).
Do not cache the Data reference across operations that may resize the buffer. Use the handle to obtain a fresh reference when needed.
Fields
Zero
A handle representing a null/invalid reference.
public static readonly JHandle<T> Zero
Field Value
- JHandle<T>
Properties
Data
Gets a reference to the underlying data.
public ref T Data { get; }
Property Value
- T
IsZero
Gets a value indicating whether this handle is null/invalid.
public bool IsZero { get; }
Property Value
Methods
AsHandle<TConvert>(JHandle<T>)
Reinterprets a handle as a handle to a different type. Both types must have compatible layouts.
public static JHandle<TConvert> AsHandle<TConvert>(JHandle<T> handle) where TConvert : unmanaged
Parameters
handleJHandle<T>The handle to reinterpret.
Returns
- JHandle<TConvert>
A handle reinterpreted as the target type.
Type Parameters
TConvertThe target unmanaged type to reinterpret as.
Remarks
Safety: The caller must ensure that T and TConvert
have compatible memory layouts. No runtime validation is performed.
Equals(JHandle<T>)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(JHandle<T> other)
Parameters
otherJHandle<T>An object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Operators
operator ==(JHandle<T>, JHandle<T>)
public static bool operator ==(JHandle<T> left, JHandle<T> right)
Parameters
Returns
operator !=(JHandle<T>, JHandle<T>)
public static bool operator !=(JHandle<T> left, JHandle<T> right)