Add buf_01#20
Conversation
…ting TrackedMemorySegmentLeases; add writing and changing position/limit to TrackedMemorySegmentLease; spotless applied
| import java.io.IOException; | ||
| import java.nio.ByteBuffer; | ||
| import java.nio.channels.SocketChannel; | ||
| import java.util.ArrayList; |
There was a problem hiding this comment.
I was trying to avoid List conversions from arrays[] as they come with allocation overhead. Have you measured the impact in profiler? Same goes to all new calls.
fixes port in use error
| for (ByteBuffer byteBuffer : buffers()) { | ||
| byteBuffer.limit(0); | ||
| for (final TrackedLease<MemorySegment> lease : memorySegmentLeases()) { | ||
| try { |
There was a problem hiding this comment.
It can throw IllegalStateException; however AutoCloseable interface defines that it throws Exception on close. I think buf_01 Lease interface needs to define a different exception in interface to work around this.
| if (!allWritten && bytesWritten > 0) { | ||
| // same as ByteBuffer.flip() | ||
| final long diff = bytesLeft - byteSize; | ||
| if (diff < 0) { |
There was a problem hiding this comment.
nested control structures are error prone. please consider simplifying
| if (!allRead && readBytes > 0) { | ||
| // same as ByteBuffer.flip() | ||
| final long diff = bytesLeft - byteSize; | ||
| if (diff < 0) { |
There was a problem hiding this comment.
nested control structures are error prone. please consider simplifying
…ith .removeFirst operation.
|
|
||
| private long readData() throws IOException { | ||
| long readBytes = 0; | ||
| final List<OpenableLease<MemorySegment>> bufferLeases = new LeaseMultiGet(memorySegmentLeasePool).get(4); |
There was a problem hiding this comment.
would it be feasible to change multiget to return an array?
There was a problem hiding this comment.
if this uses TrackedMemorySegmentLease's always, would it be better to return alwayys them ready as TrackedMemorySegmentLeases via a decorator?
There was a problem hiding this comment.
I think it would be quite trivial change, however it would be done in buf_01 project
Uh oh!
There was an error while loading. Please reload this page.