Table of Contents

Struct JHandle<T>

Namespace
Jitter2.Unmanaged
Assembly
Jitter2.dll

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

T

The unmanaged type of the data.

Implements
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

bool

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

handle JHandle<T>

The handle to reinterpret.

Returns

JHandle<TConvert>

A handle reinterpreted as the target type.

Type Parameters

TConvert

The 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

other JHandle<T>

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and 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

left JHandle<T>
right JHandle<T>

Returns

bool

operator !=(JHandle<T>, JHandle<T>)

public static bool operator !=(JHandle<T> left, JHandle<T> right)

Parameters

left JHandle<T>
right JHandle<T>

Returns

bool