Commit Graph

9 Commits

Author SHA1 Message Date
Chris Vest
e6a238b14d Add features to MemoryManager
The ability to allocate a buffer on a sub-region of some recoverable memory will be useful when porting over the arena-based pooling allocator from Netty.
2021-05-11 14:57:42 +02:00
Chris Vest
599c01b762 Make the buffer read-only state irreversible
This greatly simplifies the semantics around the const buffers.
When they can no longer be made writable, there is no longer any need for "deconstification".

I decided to call the method "makeReadOnly" to distinguish it from "asReadOnly" that is seen in ByteBuf and ByteBuffer. The latter two return read-only _views_ of the buffer, while makeReadOnly changes the state of the buffer in-place.
2021-05-05 12:30:52 +02:00
Chris Vest
51cc1e7cf4 More efficient const buffer implementations
The const buffers of the various implementations are now able to share the underlying memory.
At least until they are forced not to.
Const buffers will behave ust like normal buffers, except they start out as read-only.
When they are made writable, or sliced, then they will allocate their own independent copy of the memory.
That way, const buffers can have their contents changed, and behave just like normal buffers.
The const-ness is a pure optimisation that should not have any externally observable behaviour.
2021-05-03 15:00:49 +02:00
Chris Vest
66c2bf4e2c Rename bifurcate to split 2021-04-29 15:34:04 +02:00
Chris Vest
7775460984 Make bifurcate and ensureWritable more flexible
This supports more use cases.
The ensureWritable method can now amortise its allocation cost by allocating more than what is strictly necessary to satisfy the immediate call.
The bifurcate method can now split at a given offset.
2021-04-27 10:00:27 +02:00
Chris Vest
99efb7dab9 Fix compilation error after rebase 2021-04-08 21:10:17 +02:00
Chris Vest
fb7279e82f Fix more test failures for UnsafeBuffer 2021-04-08 14:44:58 +02:00
Chris Vest
1fe8abecfa Fix JVM crashes and a number of test failures
Still more test failures left, but getting close now.
2021-04-08 14:44:58 +02:00
Chris Vest
c73dd07384 UnsafeBuffer implementation, based on sun.misc.Unsafe
Motivation:
When Unsafe is available, we can supposedly do certain things faster than when it is not.

Modification:
Add a Buffer implementation that take advantage of sun.misc.Unsafe.
It has not yet been verified if this is faster in any way than, say the ByteBuffer implementation or the MemorySegment implementation.

Result:
Another Buffer implementation that can be used when Unsafe is available.
2021-04-08 14:44:58 +02:00