Class DoubleBuffer
public class DoubleBuffer : Buffer, IDynamicMetaObjectProvider, IJVMBridgeCore, IEquatable<IJVMBridgeBaseInstance>, IDisposable, IJVMBridgeBaseStatic, IJVMBridgeBase, IJVMBridgeBaseInstance, IJVMBridgeDefinition
- Inheritance
-
DoubleBuffer
- Implements
- Inherited Members
- Extension Methods
Constructors
DoubleBuffer(IJVMBridgeBaseInitializer)
Initializer used internally by JCOBridge. Do not use directly.
[Obsolete("This public initializer is needed for JCOBridge internal use, other uses can produce unidentible behaviors.")]
public DoubleBuffer(IJVMBridgeBaseInitializer initializer)
Parameters
initializerIJVMBridgeBaseInitializer
Properties
BridgeClassName
Java class name to be instantiated
public override string BridgeClassName { get; }
Property Value
IsBridgeAbstract
true if the BridgeClassName is an abstract class, i.e. cannot be created an instance
public override bool IsBridgeAbstract { get; }
Property Value
IsBridgeCloseable
true if the BridgeClassName implements java.lang.AutoCloseable
public override bool IsBridgeCloseable { get; }
Property Value
IsBridgeInterface
true if the BridgeClassName is an interface, i.e. does not have any public constructor
public override bool IsBridgeInterface { get; }
Property Value
IsBridgeStatic
true if the BridgeClassName is a static class, i.e. does not have any public constructor
public override bool IsBridgeStatic { get; }
Property Value
Methods
Allocate(int)
public static DoubleBuffer Allocate(int arg0)
Parameters
Returns
AsReadOnlyBuffer()
public DoubleBuffer AsReadOnlyBuffer()
Returns
Compact()
public DoubleBuffer Compact()
Returns
CompareTo(DoubleBuffer)
public int CompareTo(DoubleBuffer arg0)
Parameters
arg0DoubleBuffer
Returns
CompareTo(object)
public int CompareTo(object arg0)
Parameters
Returns
Dispose(bool)
Implements the pattern described in https://learn.microsoft.com/en-en/dotnet/standard/garbage-collection/implementing-dispose
protected override void Dispose(bool disposing)
Parameters
disposingboolThe disposing parameter is a bool that indicates whether the method call comes from a Dispose() method (its value is true) or from a finalizer (its value is false)
Duplicate()
public DoubleBuffer Duplicate()
Returns
From(JCOBridgeSharedBufferStream<double>)
Creates a new DoubleBuffer in the JVM which shares the memory of stream.
This is the preferred overload for high-rate scenarios as it avoids repeated array copies from CLR to JVM and benefits from pooled buffer management.
public static DoubleBuffer From(JCOBridgeSharedBufferStream<double> stream)
Parameters
streamJCOBridgeSharedBufferStream<double>A JCOBridgeSharedBufferStream<T> obtained from Rent(long) and populated via Stream-based APIs, to be used directly within the JVM from a DoubleBuffer.
Returns
- DoubleBuffer
A new instance of DoubleBuffer holding the memory of
streamshared with the DoubleBuffer.
Remarks
The memory associated to stream will be retained until the JVM reference of the newly created DoubleBuffer is garbage collected.
Under heavy pressure the memory footprint can raise up and generate an OutOfMemoryException; use the functionality with caution.
Lifecycle management: the subsystem automatically returns stream to the internal pool once the JVM Garbage Collector retires the associated
DoubleBuffer, i.e. when the DoubleBuffer has been fully consumed by the JVM.
A direct call to Dispose() on the returned DoubleBuffer is therefore a no-op; do not attempt to manually dispose stream after passing it to this method.
Pool strategy: the HPA (High Performance Application) runtime variant draws stream instances from a highly optimized pool tuned for high-throughput workloads,
while the standard runtime variant uses a lighter pool. In both cases the pooling is fully transparent to the caller.
Exceptions
- ArgumentException
Thrown when
streamwas not obtained through Rent(long).- NotSupportedException
Thrown when the JVM is unable to generate a DoubleBuffer instance.
From(double[], bool, int)
Creates a new DoubleBuffer in the JVM which belongs to data
public static DoubleBuffer From(double[] data, bool arrangeCapacity = true, int timeToLive = -1)
Parameters
datadouble[]The data to be shared
arrangeCapacityboolIf true the double array in
datawill be resized to the next power of 2, so capacity will be memory aligned and the limit of java.nio.DoubleBuffer will be current size ofdatatimeToLiveintThe time to live, expressed in milliseconds, the underlying memory shall remain available; if the time to live expires the pinned memory is retired leaving potentially the JVM under the possibility of an access violation.
Returns
- DoubleBuffer
A new instance of DoubleBuffer
Get()
public double Get()
Returns
Get(double[])
public DoubleBuffer Get(double[] arg0)
Parameters
Returns
Get(double[], int, int)
public DoubleBuffer Get(double[] arg0, int arg1, int arg2)
Parameters
Returns
Get(int)
public double Get(int arg0)
Parameters
Returns
Order()
public ByteOrder Order()
Returns
Put(DoubleBuffer)
public DoubleBuffer Put(DoubleBuffer arg0)
Parameters
arg0DoubleBuffer
Returns
Put(double)
public DoubleBuffer Put(double arg0)
Parameters
Returns
Put(double[])
public DoubleBuffer Put(double[] arg0)
Parameters
Returns
Put(double[], int, int)
public DoubleBuffer Put(double[] arg0, int arg1, int arg2)
Parameters
Returns
Put(int, double)
public DoubleBuffer Put(int arg0, double arg1)
Parameters
Returns
Rent(long)
Returns a JCOBridgeSharedBufferStream<T> with an initial capacity derived from capacity,
to be populated via Stream-based APIs and then passed to From(JCOBridgeSharedBufferStream<double>).
public static JCOBridgeSharedBufferStream<double> Rent(long capacity = -1)
Parameters
capacitylongThe plausible number of elements of double type to be written into the stream; the byte size is computed as
capacity * sizeof(double). The default value of-1instructs the subsystem to allocate the minimum meaningful unit, which corresponds to one system memory page (see SystemPageSize). Regardless of the value provided, the effective allocation is always rounded up to the nearest multiple of the system page size, since the underlying native allocator operates at page granularity. Passing a value smaller than one page therefore has no practical advantage over using the default. This value is a hint, not a hard limit: if the actual data written exceeds the initial allocation, the underlying buffer will grow automatically via reallocation. However, providing a value greater than or equal to the actual data size is strongly recommended to avoid reallocation overhead, especially in high-rate scenarios. Callers that process data of a known or predictable size are encouraged to implement their own estimation strategy — for example, tracking the stable size observed in previous invocations — so that the initial capacity converges toward the real value over time and reallocations become increasingly rare or disappear entirely.
Returns
- JCOBridgeSharedBufferStream<double>
A pooled instance of JCOBridgeSharedBufferStream<T> ready to be written via Stream-based APIs and then passed to From(JCOBridgeSharedBufferStream<double>).
Remarks
The returned JCOBridgeSharedBufferStream<T> is drawn from an internal pool. The HPA (High Performance Application) runtime variant uses a highly optimized pool tuned for high-throughput scenarios, while the standard runtime variant uses a lighter pool suitable for moderate workloads. The instance must not be manually disposed; its lifecycle is fully managed by the subsystem and it is automatically returned to the pool once the JVM Garbage Collector retires the associated DoubleBuffer created by From(JCOBridgeSharedBufferStream<double>).
Exceptions
- ArgumentOutOfRangeException
Thrown when
capacityis zero or any positive value that, once multiplied bysizeof(double), overflows a long.
Slice()
public DoubleBuffer Slice()
Returns
ToArray(bool)
Returns the double array managed from this DoubleBuffer
public double[] ToArray(bool bypassDirectConvert = false)
Parameters
Returns
- double[]
The double array managed from this DoubleBuffer
ToDirectBuffer(bool)
Returns an instance of JCOBridgeDirectBuffer<T> can be used to directly access and manages JVM memory without any memory move
[Obsolete("DO NOT CALL Dispose() on the returned JCOBridgeDirectBuffer: it is an internal instance whose lifetime is managed by the owning object.", false)]
public JCOBridgeDirectBuffer<double> ToDirectBuffer(bool rewind)
Parameters
rewindboolRewind() the instance before return JCOBridgeDirectBuffer<T>
Returns
- JCOBridgeDirectBuffer<double>
The JCOBridgeDirectBuffer<T> associated to this DoubleBuffer instance
Remarks
Do not call Dispose() on the returned instance. Its lifetime is managed by the owning object.
Wrap(double[])
public static DoubleBuffer Wrap(double[] arg0)
Parameters
Returns
Wrap(double[], int, int)
public static DoubleBuffer Wrap(double[] arg0, int arg1, int arg2)
Parameters
Returns
Operators
implicit operator Comparable(DoubleBuffer)
Converter from DoubleBuffer to Comparable
public static implicit operator Comparable(DoubleBuffer t)
Parameters
Returns
implicit operator Comparable<DoubleBuffer>(DoubleBuffer)
Converter from DoubleBuffer to Comparable<T>
public static implicit operator Comparable<DoubleBuffer>(DoubleBuffer buffer)
Parameters
bufferDoubleBuffer
Returns
implicit operator JCOBridgeDirectBuffer<double>(DoubleBuffer)
Converts an instance of DoubleBuffer into JCOBridgeDirectBuffer<T>
public static implicit operator JCOBridgeDirectBuffer<double>(DoubleBuffer t)
Parameters
Returns
implicit operator double[](DoubleBuffer)
Converts an instance of DoubleBuffer into double array
public static implicit operator double[](DoubleBuffer t)
Parameters
Returns
- double[]
Remarks
If the DoubleBuffer supports direct access the function tries to move data from JVM memory without JNI, otherwise fallback to the standard memory copy.
implicit operator DoubleBuffer(double[])
Converts an instance of double array into DoubleBuffer using the default parameters of From(double[], bool, int)
public static implicit operator DoubleBuffer(double[] t)
Parameters
tdouble[]
Returns
Remarks
If the JVM supports direct access the function will share with the JVM the memory without JNI, otherwise fallback to the standard memory copy.