Top Inners Fields Constructors Methods
org.jruby.ext.ffi.jffi

pack-priv final Class AllocatedNativeMemoryIO

extends BoundedNativeMemoryIO
implements AllocatedDirectMemoryIO
Class Inheritance
All Implemented Interfaces
org.jruby.ext.ffi.AllocatedDirectMemoryIO
Imports
java.lang.ref.Reference, .SoftReference, .WeakReference, java.util.Map, java.util.concurrent.ConcurrentHashMap, org.jruby.Ruby, org.jruby.ext.ffi.AllocatedDirectMemoryIO, org.jruby.util.PhantomReferenceReaper

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
AllocatedNativeMemoryIO.AllocationGroup

Holder for a group of memory allocations.

private static class
AllocatedNativeMemoryIO.MemoryAllocation

Represents a single native memory allocation

Field Summary

Modifier and TypeField and Description
private final AllocatedNativeMemoryIO.MemoryAllocation
private static final ThreadLocal<Reference<AllocatedNativeMemoryIO.AllocationGroup>>
private static final Map<AllocatedNativeMemoryIO.AllocationGroup, Boolean>
referenceSet

Keeps strong references to the memory bucket until cleanup

private final Object
Inherited from org.jruby.ext.ffi.jffi.BoundedNativeMemoryIO:
ADDRESS_SIZEIOLONG_SIZEparentsize

Constructor Summary

AccessConstructor and Description
private
AllocatedNativeMemoryIO(Ruby runtime, Object sentinel, long address, int size, int align)

Method Summary

Modifier and TypeMethod and Description
pack-priv static final AllocatedNativeMemoryIO
allocate(Ruby
The Ruby runtime
runtime
,
int
The number of bytes to allocate
size
,
boolean
Whether the memory should be cleared (zeroed)
clear
)

Allocates native memory

pack-priv static AllocatedNativeMemoryIO
allocateAligned(Ruby
The Ruby runtime
runtime
,
int
The number of bytes to allocate
size
,
int
The minimum alignment of the memory
align
,
boolean
Whether the memory should be cleared (zeroed)
clear
)

Allocates native memory, aligned to a minimum boundary.

public void
public boolean
public void
Inherited from org.jruby.ext.ffi.jffi.BoundedNativeMemoryIO:
arrayarrayLengtharrayOffsetasByteBufferdupequalsgetgetgetgetgetgetgetAddressgetBytegetDoublegetFloatgetIntgetLonggetMemoryIOgetNativeLonggetRuntimegetShortgetZeroTerminatedByteArraygetZeroTerminatedByteArrayhashCodeindexOfindexOforderputputputputputputputAddressputByteputDoubleputFloatputIntputLongputMemoryIOputNativeLongputShortputZeroTerminatedByteArraysetMemorysliceslice

Field Detail

allocationback to summary
private final AllocatedNativeMemoryIO.MemoryAllocation allocation
currentBucketback to summary
private static final ThreadLocal<Reference<AllocatedNativeMemoryIO.AllocationGroup>> currentBucket
referenceSetback to summary
private static final Map<AllocatedNativeMemoryIO.AllocationGroup, Boolean> referenceSet

Keeps strong references to the memory bucket until cleanup

sentinelback to summary
private final Object sentinel

Constructor Detail

AllocatedNativeMemoryIOback to summary
private AllocatedNativeMemoryIO(Ruby runtime, Object sentinel, long address, int size, int align)

Method Detail

allocateback to summary
pack-priv static final AllocatedNativeMemoryIO allocate(Ruby runtime, int size, boolean clear)

Allocates native memory

Parameters
runtime:Ruby

The Ruby runtime

size:int

The number of bytes to allocate

clear:boolean

Whether the memory should be cleared (zeroed)

Returns:AllocatedNativeMemoryIO

A new AllocatedDirectMemoryIO

allocateAlignedback to summary
pack-priv static AllocatedNativeMemoryIO allocateAligned(Ruby runtime, int size, int align, boolean clear)

Allocates native memory, aligned to a minimum boundary.

Parameters
runtime:Ruby

The Ruby runtime

size:int

The number of bytes to allocate

align:int

The minimum alignment of the memory

clear:boolean

Whether the memory should be cleared (zeroed)

Returns:AllocatedNativeMemoryIO

A new AllocatedDirectMemoryIO

freeback to summary
public void free()

Implements org.jruby.ext.ffi.AllocatedDirectMemoryIO.free.

isAutoReleaseback to summary
public boolean isAutoRelease()

Implements org.jruby.ext.ffi.AllocatedDirectMemoryIO.isAutoRelease.

setAutoReleaseback to summary
public void setAutoRelease(boolean autorelease)

Implements org.jruby.ext.ffi.AllocatedDirectMemoryIO.setAutoRelease.

org.jruby.ext.ffi.jffi back to summary

private final Class AllocatedNativeMemoryIO.AllocationGroup

extends PhantomReferenceReaper<Object>
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Holder for a group of memory allocations.

Field Summary

Modifier and TypeField and Description
private long
private volatile AllocatedNativeMemoryIO.MemoryAllocation
public static final int
private final WeakReference<Object>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv boolean
canAccept(int size)

public final void
run()

Implements java.lang.Runnable.run.

Runs this operation.

pack-priv Object

Field Detail

bytesUsedback to summary
private long bytesUsed
headback to summary
private volatile AllocatedNativeMemoryIO.MemoryAllocation head
MAX_BYTES_PER_BUCKETback to summary
public static final int MAX_BYTES_PER_BUCKET
weakrefback to summary
private final WeakReference<Object> weakref

Constructor Detail

AllocationGroupback to summary
pack-priv AllocationGroup(Object sentinel)

Method Detail

addback to summary
pack-priv void add(AllocatedNativeMemoryIO.MemoryAllocation m, int size)
canAcceptback to summary
pack-priv boolean canAccept(int size)
runback to summary
public final void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

sentinelback to summary
pack-priv Object sentinel()
org.jruby.ext.ffi.jffi back to summary

private final Class AllocatedNativeMemoryIO.MemoryAllocation

extends Object
Class Inheritance
  • java.lang.Object
  • org.jruby.ext.ffi.jffi.AllocatedNativeMemoryIO.MemoryAllocation

Represents a single native memory allocation

Field Summary

Modifier and TypeField and Description
private final long
pack-priv volatile AllocatedNativeMemoryIO.MemoryAllocation
pack-priv volatile boolean
pack-priv volatile boolean

Constructor Summary

AccessConstructor and Description
pack-priv
MemoryAllocation(long address)

Method Summary

Modifier and TypeMethod and Description
pack-priv final void
pack-priv final void
free()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addressback to summary
private final long address
nextback to summary
pack-priv volatile AllocatedNativeMemoryIO.MemoryAllocation next
releasedback to summary
pack-priv volatile boolean released
unmanagedback to summary
pack-priv volatile boolean unmanaged

Constructor Detail

MemoryAllocationback to summary
pack-priv MemoryAllocation(long address)

Method Detail

disposeback to summary
pack-priv final void dispose()
freeback to summary
pack-priv final void free()