Click or drag to resize

JCOBridgeDirectBufferT Class

A class to manage shared memory between .NET and JVM using a memory region created from the CLR and shared with the JVM using https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html
Inheritance Hierarchy
SystemObject
  MASES.JCOBridge.C2JBridgeJCOBridgeDirectBufferT

Namespace: MASES.JCOBridge.C2JBridge
Assembly: C2JBridge (in C2JBridge.dll) Version: 2.6.9.260611-9a148513a79c26cdd7f1dde468f4f9e06ef3bc7e
Syntax
public sealed class JCOBridgeDirectBuffer<T> : IJVMBridgeBaseInstance, 
	IEnumerable<T>, IEnumerable, IDisposable
where T : struct, new()

Type Parameters

T
The Type to be used: it can be any Byte, Int16, Int32, Int64, Single, Double or a type defined as a struct

The JCOBridgeDirectBufferT type exposes the following members.

Properties
 NameDescription
Public propertyBridgeInstance The IJavaObject instance
Public propertyDynBridgeInstance The dynamic accessor to BridgeInstance
Public propertyItem Get or set the element at index.
Public propertyJavaObject The IJavaObject referring to the https://docs.oracle.com/javase/8/docs/api/java/nio/ByteBuffer.html managing the maoping
Obsolete
Top
Methods
 NameDescription
Public methodAsTNew Returns a new instance of JCOBridgeDirectBufferT
Public methodAsSpan Returns a zero-copy ReadOnlySpanT over the entire buffer, starting at offset zero regardless of the current position.
Public methodAsSpanFromIndex Returns a zero-copy ReadOnlySpanT over the buffer starting at the specified element index.
Public methodAsWritableSpan Returns a zero-copy writable SpanT over the entire buffer, starting at offset zero regardless of the current position.

Contract: if any element is modified through the returned span, FlushOnDispose MUST be called before Dispose to ensure changes are written back. Failing to do so results in silent data loss. For single or sparse writes prefer Write(...), which sets the flush flag automatically.

Public methodAsWritableSpanFromIndex Returns a zero-copy writable SpanT over the buffer starting at the specified element index.

Contract: if any element is modified through the returned span, FlushOnDispose MUST be called before Dispose to ensure changes are written back. Failing to do so results in silent data loss. For single or sparse writes prefer Write(...), which sets the flush flag automatically.

Public methodCopyTo(T, Int32) Copies the content of the buffer into destination.

On .NET 5+ and .NET Standard 2.1 dispatches to SIMD hardware intrinsics via AsSpan. On .NET Framework uses Buffer.MemoryCopy directly; if System.Memory is available in the AppDomain the SIMD path is activated automatically — see remarks on CopyTo(T, Int32) for loading instructions.

Public methodCopyTo(IntPtr, Int64, Int64, Int64) Fills the destination with a copy of the memory this JCOBridgeDirectBufferT instance is holding from the underlying ByteBuffer. The number of bytes actually copied may be less than length if the remaining bytes from startPosition to the buffer limit or destinationSize are smaller.
Public methodDisableCleanup Disable the internal object clean-up upon Dispose
Public methodDisableCleanupAndReturn Helper method to execute DisableCleanup and return the internal IJavaObject
Public methodDispose Execute Dispose activities releasing the underlying .NET memory pinned when the JCOBridgeDirectBufferT was requested
Public methodEnableCleanup Enable the internal object clean-up upon Dispose
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodFillWithArrayTArray Copies the content of array into memory managed from this JCOBridgeDirectBufferT instance
Protected methodFinalize Finalizer
(Overrides ObjectFinalize)
Public methodFlushOnDispose Marks this stream to flush all native memory changes back to the underlying resource on Dispose.

Must be called after any direct write performed through AsWritableSpan or AsWritableSpanFromIndex(Int32) before the stream is closed.

This method is idempotent — calling it multiple times has no additional effect.

Public methodGetEnumeratorReturns an enumerator that iterates through the collection.
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodGetValue(Int32)Gets the value at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.
Public methodGetValue(Int64)Gets the value at the specified position in the one-dimensional Array. The index is specified as a 64-bit integer.
Public methodInitializeInitializes every element of the value-type Array by calling the default constructor of the value type.
Public methodSetValue(T, Int32)Sets a value to the element at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.
Public methodSetValue(T, Int64)Sets a value to the element at the specified position in the one-dimensional Array. The index is specified as a 64-bit integer.
Public methodToArray(T, Boolean) Fills array with a reinterpreted copy of the memory this JCOBridgeDirectBufferT instance is holding. Use only when TArray differs from T; for same-type copies prefer CopyTo(T, Int32).
Public methodToArrayTArray Returns a TArray array which is the copy of the memory this JCOBridgeDirectBufferT instance is holding
Public methodToArrayTArray(TArray, Boolean) Fills array with a reinterpreted copy of the memory this JCOBridgeDirectBufferT instance is holding. Use only when TArray differs from T; for same-type copies prefer CopyTo(T, Int32).
Public methodToStream Converts this instance to a Stream can be used to manage directly the underlying memory without make intermediate array copy
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Operators
 NameDescription
Public operatorStatic member(JCOBridgeDirectBufferT to T) Returns a T array which is the copy of the memory the t instance is holding
Public operatorStatic member(JCOBridgeDirectBufferT to Stream) Converts this instance to a Stream can be used to manage directly the underlying memory without make intermediate array copy
Top
Extension Methods
 NameDescription
Public Extension MethodConvertTReturn Converts a generic object
(Defined by JCOBridgeExtensions)
Public Extension MethodToNative Converts a IJVMBridgeBase input to an object manageable from the JVM
(Defined by JCOBridgeExtensions)
Public Extension MethodToNative Converts a generic input to an object manageable from the JVM
(Defined by JCOBridgeExtensions)
Top
Explicit Interface Implementations
 NameDescription
Explicit interface implementationPrivate methodIEnumerableGetEnumeratorReturns an enumerator that iterates through a collection.
Top
See Also