Package org.jruby.ext.ffi.jffi
Class CachingNativeMemoryAllocator
java.lang.Object
org.jruby.ext.ffi.jffi.CachingNativeMemoryAllocator
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classprivate static final classprivate static final classprivate static final classprivate static final classprivate static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final CachingNativeMemoryAllocator.Bucket[]Keeps strong references to the memory bucket until cleanupprivate static final ThreadLocal<Reference<CachingNativeMemoryAllocator.Allocator>>protected static final com.kenai.jffi.MemoryIOprivate static final Map<CachingNativeMemoryAllocator.AllocationGroup,Boolean> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static longalign(long offset, long align) (package private) static MemoryIOallocateAligned(Ruby runtime, int size, int align, boolean clear) Allocates native memory, aligned to a minimum boundary.(package private) static intbucketIndex(int size) (package private) static voidclearMemory(long address, int size) (package private) static introundUpToPowerOf2(int n)
-
Field Details
-
IO
protected static final com.kenai.jffi.MemoryIO IO -
buckets
Keeps strong references to the memory bucket until cleanup -
referenceSet
-
currentAllocator
private static final ThreadLocal<Reference<CachingNativeMemoryAllocator.Allocator>> currentAllocator
-
-
Constructor Details
-
CachingNativeMemoryAllocator
CachingNativeMemoryAllocator()
-
-
Method Details
-
bucketIndex
static int bucketIndex(int size) -
allocateAligned
Allocates native memory, aligned to a minimum boundary.- Parameters:
runtime- The Ruby runtimesize- The number of bytes to allocatealign- The minimum alignment of the memoryclear- Whether the memory should be cleared (zeroed)- Returns:
- A new
AllocatedDirectMemoryIO
-
align
private static long align(long offset, long align) -
roundUpToPowerOf2
static int roundUpToPowerOf2(int n) -
clearMemory
static void clearMemory(long address, int size)
-