Package org.lwjgl.system.jemalloc
Class ChunkHooks
- java.lang.Object
-
- org.lwjgl.system.Pointer.Default
-
- org.lwjgl.system.Struct
-
- org.lwjgl.system.jemalloc.ChunkHooks
-
- All Implemented Interfaces:
- java.lang.AutoCloseable, NativeResource, Pointer
public class ChunkHooks extends Struct
Comprises function pointers which are described individually below. jemalloc uses these functions to manage chunk lifetime, which starts off with allocation of mapped committed memory, in the simplest case followed by deallocation. However, there are performance and platform reasons to retain chunks for later reuse. Cleanup attempts cascade from deallocation to decommit to purging, which gives the chunk management functions opportunities to reject the most permanent cleanup operations in favor of less permanent (and often less costly) operations. The chunk splitting and merging operations can also be opted out of, but this is mainly intended to support platforms on which virtual memory mappings provided by the operating system kernel do not automatically coalesce and split, e.g. Windows.Member documentation
alloc
– the chunk allocation hookdalloc
– the chunk deallocation hookcommit
– the chunk commit hookdecommit
– the chunk decommit hookpurge
– the chunk purge hooksplit
– the chunk split hookmerge
– the chunk merge hook
Layout
struct chunk_hooks_t { chunk_alloc_t alloc; chunk_dalloc_t dalloc; chunk_commit_t commit; chunk_decommit_t decommit; chunk_purge_t purge; chunk_split_t split; chunk_merge_t merge; }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
ChunkHooks.Buffer
An array ofChunkHooks
structs.-
Nested classes/interfaces inherited from interface org.lwjgl.system.Pointer
Pointer.Default
-
-
Field Summary
Fields Modifier and Type Field and Description static int
SIZEOF
The struct size in bytes.-
Fields inherited from interface org.lwjgl.system.Pointer
POINTER_SHIFT, POINTER_SIZE
-
-
Constructor Summary
Constructors Constructor and Description ChunkHooks(java.nio.ByteBuffer container)
Creates aChunkHooks
instance at the current position of the specifiedByteBuffer
container.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description ChunkAlloc
alloc()
Returns theChunkAlloc
instance at thealloc
field.ChunkHooks
alloc(ChunkAllocI value)
Sets the address of the specifiedChunkAllocI
to thealloc
field.static ChunkHooks
calloc()
Returns a newChunkHooks
instance allocated withmemCalloc
.static ChunkHooks.Buffer
calloc(int capacity)
Returns a newChunkHooks.Buffer
instance allocated withmemCalloc
.static ChunkHooks
callocStack()
Returns a newChunkHooks
instance allocated on the thread-localMemoryStack
and initializes all its bits to zero.static ChunkHooks.Buffer
callocStack(int capacity)
Returns a newChunkHooks.Buffer
instance allocated on the thread-localMemoryStack
and initializes all its bits to zero.static ChunkHooks.Buffer
callocStack(int capacity, MemoryStack stack)
Returns a newChunkHooks.Buffer
instance allocated on the specifiedMemoryStack
and initializes all its bits to zero.static ChunkHooks
callocStack(MemoryStack stack)
Returns a newChunkHooks
instance allocated on the specifiedMemoryStack
and initializes all its bits to zero.ChunkCommit
commit()
Returns theChunkCommit
instance at thecommit
field.ChunkHooks
commit(ChunkCommitI value)
Sets the address of the specifiedChunkCommitI
to thecommit
field.static ChunkHooks
create()
Returns a newChunkHooks
instance allocated withBufferUtils
.static ChunkHooks.Buffer
create(int capacity)
Returns a newChunkHooks.Buffer
instance allocated withBufferUtils
.static ChunkHooks
create(long address)
static ChunkHooks.Buffer
create(long address, int capacity)
Create aChunkHooks.Buffer
instance at the specified memory.ChunkDalloc
dalloc()
Returns theChunkDalloc
instance at thedalloc
field.ChunkHooks
dalloc(ChunkDallocI value)
Sets the address of the specifiedChunkDallocI
to thedalloc
field.ChunkDecommit
decommit()
Returns theChunkDecommit
instance at thedecommit
field.ChunkHooks
decommit(ChunkDecommitI value)
Sets the address of the specifiedChunkDecommitI
to thedecommit
field.static ChunkHooks
malloc()
Returns a newChunkHooks
instance allocated withmemAlloc
.static ChunkHooks.Buffer
malloc(int capacity)
Returns a newChunkHooks.Buffer
instance allocated withmemAlloc
.static ChunkHooks
mallocStack()
Returns a newChunkHooks
instance allocated on the thread-localMemoryStack
.static ChunkHooks.Buffer
mallocStack(int capacity)
Returns a newChunkHooks.Buffer
instance allocated on the thread-localMemoryStack
.static ChunkHooks.Buffer
mallocStack(int capacity, MemoryStack stack)
Returns a newChunkHooks.Buffer
instance allocated on the specifiedMemoryStack
.static ChunkHooks
mallocStack(MemoryStack stack)
Returns a newChunkHooks
instance allocated on the specifiedMemoryStack
.ChunkMerge
merge()
Returns theChunkMerge
instance at themerge
field.ChunkHooks
merge(ChunkMergeI value)
Sets the address of the specifiedChunkMergeI
to themerge
field.ChunkHooks
nset(long struct)
Unsafe version ofset
.ChunkPurge
purge()
Returns theChunkPurge
instance at thepurge
field.ChunkHooks
purge(ChunkPurgeI value)
Sets the address of the specifiedChunkPurgeI
to thepurge
field.ChunkHooks
set(ChunkAllocI alloc, ChunkDallocI dalloc, ChunkCommitI commit, ChunkDecommitI decommit, ChunkPurgeI purge, ChunkSplitI split, ChunkMergeI merge)
Initializes this struct with the specified values.ChunkHooks
set(ChunkHooks src)
Copies the specified struct data to this struct.int
sizeof()
Returns thesizeof(struct)
.ChunkSplit
split()
Returns theChunkSplit
instance at thesplit
field.ChunkHooks
split(ChunkSplitI value)
Sets the address of the specifiedChunkSplitI
to thesplit
field.static void
validate(long struct)
Validates pointer members that should not beNULL
.static void
validate(long array, int count)
CallsChunkHooks.validate(long)
for each struct contained in the specified struct array.-
Methods inherited from class org.lwjgl.system.Pointer.Default
address, equals, hashCode, toString
-
Methods inherited from interface org.lwjgl.system.NativeResource
close
-
-
-
-
Constructor Detail
-
ChunkHooks
public ChunkHooks(java.nio.ByteBuffer container)
Creates aChunkHooks
instance at the current position of the specifiedByteBuffer
container. Changes to the buffer's content will be visible to the struct instance and vice versa.The created instance holds a strong reference to the container object.
-
-
Method Detail
-
sizeof
public int sizeof()
Description copied from class:Struct
Returns thesizeof(struct)
.
-
alloc
public ChunkAlloc alloc()
Returns theChunkAlloc
instance at thealloc
field.
-
dalloc
public ChunkDalloc dalloc()
Returns theChunkDalloc
instance at thedalloc
field.
-
commit
public ChunkCommit commit()
Returns theChunkCommit
instance at thecommit
field.
-
decommit
public ChunkDecommit decommit()
Returns theChunkDecommit
instance at thedecommit
field.
-
purge
public ChunkPurge purge()
Returns theChunkPurge
instance at thepurge
field.
-
split
public ChunkSplit split()
Returns theChunkSplit
instance at thesplit
field.
-
merge
public ChunkMerge merge()
Returns theChunkMerge
instance at themerge
field.
-
alloc
public ChunkHooks alloc(ChunkAllocI value)
Sets the address of the specifiedChunkAllocI
to thealloc
field.
-
dalloc
public ChunkHooks dalloc(ChunkDallocI value)
Sets the address of the specifiedChunkDallocI
to thedalloc
field.
-
commit
public ChunkHooks commit(ChunkCommitI value)
Sets the address of the specifiedChunkCommitI
to thecommit
field.
-
decommit
public ChunkHooks decommit(ChunkDecommitI value)
Sets the address of the specifiedChunkDecommitI
to thedecommit
field.
-
purge
public ChunkHooks purge(ChunkPurgeI value)
Sets the address of the specifiedChunkPurgeI
to thepurge
field.
-
split
public ChunkHooks split(ChunkSplitI value)
Sets the address of the specifiedChunkSplitI
to thesplit
field.
-
merge
public ChunkHooks merge(ChunkMergeI value)
Sets the address of the specifiedChunkMergeI
to themerge
field.
-
set
public ChunkHooks set(ChunkAllocI alloc, ChunkDallocI dalloc, ChunkCommitI commit, ChunkDecommitI decommit, ChunkPurgeI purge, ChunkSplitI split, ChunkMergeI merge)
Initializes this struct with the specified values.
-
nset
public ChunkHooks nset(long struct)
Unsafe version ofset
.
-
set
public ChunkHooks set(ChunkHooks src)
Copies the specified struct data to this struct.- Parameters:
src
- the source struct- Returns:
- this struct
-
malloc
public static ChunkHooks malloc()
Returns a newChunkHooks
instance allocated withmemAlloc
. The instance must be explicitly freed.
-
calloc
public static ChunkHooks calloc()
Returns a newChunkHooks
instance allocated withmemCalloc
. The instance must be explicitly freed.
-
create
public static ChunkHooks create()
Returns a newChunkHooks
instance allocated withBufferUtils
.
-
create
public static ChunkHooks create(long address)
-
malloc
public static ChunkHooks.Buffer malloc(int capacity)
Returns a newChunkHooks.Buffer
instance allocated withmemAlloc
. The instance must be explicitly freed.- Parameters:
capacity
- the buffer capacity
-
calloc
public static ChunkHooks.Buffer calloc(int capacity)
Returns a newChunkHooks.Buffer
instance allocated withmemCalloc
. The instance must be explicitly freed.- Parameters:
capacity
- the buffer capacity
-
create
public static ChunkHooks.Buffer create(int capacity)
Returns a newChunkHooks.Buffer
instance allocated withBufferUtils
.- Parameters:
capacity
- the buffer capacity
-
create
public static ChunkHooks.Buffer create(long address, int capacity)
Create aChunkHooks.Buffer
instance at the specified memory.- Parameters:
address
- the memory addresscapacity
- the buffer capacity
-
mallocStack
public static ChunkHooks mallocStack()
Returns a newChunkHooks
instance allocated on the thread-localMemoryStack
.
-
callocStack
public static ChunkHooks callocStack()
Returns a newChunkHooks
instance allocated on the thread-localMemoryStack
and initializes all its bits to zero.
-
mallocStack
public static ChunkHooks mallocStack(MemoryStack stack)
Returns a newChunkHooks
instance allocated on the specifiedMemoryStack
.- Parameters:
stack
- the stack from which to allocate
-
callocStack
public static ChunkHooks callocStack(MemoryStack stack)
Returns a newChunkHooks
instance allocated on the specifiedMemoryStack
and initializes all its bits to zero.- Parameters:
stack
- the stack from which to allocate
-
mallocStack
public static ChunkHooks.Buffer mallocStack(int capacity)
Returns a newChunkHooks.Buffer
instance allocated on the thread-localMemoryStack
.- Parameters:
capacity
- the buffer capacity
-
callocStack
public static ChunkHooks.Buffer callocStack(int capacity)
Returns a newChunkHooks.Buffer
instance allocated on the thread-localMemoryStack
and initializes all its bits to zero.- Parameters:
capacity
- the buffer capacity
-
mallocStack
public static ChunkHooks.Buffer mallocStack(int capacity, MemoryStack stack)
Returns a newChunkHooks.Buffer
instance allocated on the specifiedMemoryStack
.- Parameters:
stack
- the stack from which to allocatecapacity
- the buffer capacity
-
callocStack
public static ChunkHooks.Buffer callocStack(int capacity, MemoryStack stack)
Returns a newChunkHooks.Buffer
instance allocated on the specifiedMemoryStack
and initializes all its bits to zero.- Parameters:
stack
- the stack from which to allocatecapacity
- the buffer capacity
-
validate
public static void validate(long struct)
Validates pointer members that should not beNULL
.- Parameters:
struct
- the struct to validate
-
validate
public static void validate(long array, int count)
CallsChunkHooks.validate(long)
for each struct contained in the specified struct array.- Parameters:
array
- the struct array to validatecount
- the number of structs inarray
-
-