Class LockFreePrefixTree.ObjectPoolingAllocator
java.lang.Object
org.graalvm.collections.LockFreePrefixTree.Allocator
org.graalvm.collections.LockFreePrefixTree.ObjectPoolingAllocator
- Enclosing class:
LockFreePrefixTree
Allocator that internally maintains several pools of preallocated objects, and allocates
objects from those pools. This allocator is guaranteed not to allocate any objects inside the
invocations to its methods.
To ensure that the internal pools have sufficiently many preallocated objects, this allocator
has a housekeeping thread that periodically wakes up, allocates objects and inserts them into
the pools. This allocator tracks the requests that failed since the last housekeeping
session, and the housekeeping thread will strive to accomodate requests that have not been
fulfilled since the last housekeeping session (i.e. it will preallocate those types of
additional objects whose allocation request previously failed, and it will allocate at least
as many objects as there were previous failed allocation requests).
This implementation only allows allocating
Node.LinearChildren and
Node.HashChildren arrays whose length is a power of 2 (because
LockFreePrefixTree only ever allocates arrays that are a power of 2). If the
requested array length is not a power of 2, an exception is thrown.- Since:
- 23.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.graalvm.collections.LockFreePrefixTree.Node.HashChildrennewHashChildren(int length) Allocates a new reference array of child nodes stored as a hash table.org.graalvm.collections.LockFreePrefixTree.Node.LinearChildrennewLinearChildren(int length) Allocates a new reference array of child nodes stored linearly.newNode(long key) Allocates a new Node object.voidshutdown()Releases the allocator's resources.status()
-
Constructor Details
-
ObjectPoolingAllocator
public ObjectPoolingAllocator()- Since:
- 23.0
-
ObjectPoolingAllocator
public ObjectPoolingAllocator(int housekeepingPeriodMillis) - Since:
- 23.0
-
-
Method Details
-
newNode
Description copied from class:LockFreePrefixTree.AllocatorAllocates a new Node object.- Specified by:
newNodein classLockFreePrefixTree.Allocator- Parameters:
key- The key to use for theNodeobject.- Returns:
- A fresh
Nodeobject, possibly preallocated. - Since:
- 23.0
-
newLinearChildren
public org.graalvm.collections.LockFreePrefixTree.Node.LinearChildren newLinearChildren(int length) Description copied from class:LockFreePrefixTree.AllocatorAllocates a new reference array of child nodes stored linearly.- Specified by:
newLinearChildrenin classLockFreePrefixTree.Allocator- Parameters:
length- The length of the allocated array.- Returns:
- A fresh array, possibly preallocated.
- Since:
- 23.0
-
newHashChildren
public org.graalvm.collections.LockFreePrefixTree.Node.HashChildren newHashChildren(int length) Description copied from class:LockFreePrefixTree.AllocatorAllocates a new reference array of child nodes stored as a hash table.- Specified by:
newHashChildrenin classLockFreePrefixTree.Allocator- Parameters:
length- The length of the allocated array.- Returns:
- A fresh array, possibly preallocated.
- Since:
- 23.0
-
shutdown
public void shutdown()Description copied from class:LockFreePrefixTree.AllocatorReleases the allocator's resources. Allocator should not be used after calling this method.- Specified by:
shutdownin classLockFreePrefixTree.Allocator- Since:
- 23.0
-
status
-