Also allow to override how direct ByteBuffers are freed
This commit is contained in:
parent
9b7d286652
commit
d11d3a6b50
@ -109,13 +109,20 @@ public class UnpooledDirectByteBuf extends AbstractReferenceCountedByteBuf {
|
|||||||
return ByteBuffer.allocateDirect(initialCapacity);
|
return ByteBuffer.allocateDirect(initialCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free a direct {@link ByteBuffer}
|
||||||
|
*/
|
||||||
|
protected void freeDirect(ByteBuffer buffer) {
|
||||||
|
PlatformDependent.freeDirectBuffer(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
private void setByteBuffer(ByteBuffer buffer) {
|
private void setByteBuffer(ByteBuffer buffer) {
|
||||||
ByteBuffer oldBuffer = this.buffer;
|
ByteBuffer oldBuffer = this.buffer;
|
||||||
if (oldBuffer != null) {
|
if (oldBuffer != null) {
|
||||||
if (doNotFree) {
|
if (doNotFree) {
|
||||||
doNotFree = false;
|
doNotFree = false;
|
||||||
} else {
|
} else {
|
||||||
PlatformDependent.freeDirectBuffer(oldBuffer);
|
freeDirect(oldBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,7 +602,7 @@ public class UnpooledDirectByteBuf extends AbstractReferenceCountedByteBuf {
|
|||||||
this.buffer = null;
|
this.buffer = null;
|
||||||
|
|
||||||
if (!doNotFree) {
|
if (!doNotFree) {
|
||||||
PlatformDependent.freeDirectBuffer(buffer);
|
freeDirect(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leak != null) {
|
if (leak != null) {
|
||||||
|
@ -112,13 +112,20 @@ public class UnpooledUnsafeDirectByteBuf extends AbstractReferenceCountedByteBuf
|
|||||||
return ByteBuffer.allocateDirect(initialCapacity);
|
return ByteBuffer.allocateDirect(initialCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free a direct {@link ByteBuffer}
|
||||||
|
*/
|
||||||
|
protected void freeDirect(ByteBuffer buffer) {
|
||||||
|
PlatformDependent.freeDirectBuffer(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
private void setByteBuffer(ByteBuffer buffer) {
|
private void setByteBuffer(ByteBuffer buffer) {
|
||||||
ByteBuffer oldBuffer = this.buffer;
|
ByteBuffer oldBuffer = this.buffer;
|
||||||
if (oldBuffer != null) {
|
if (oldBuffer != null) {
|
||||||
if (doNotFree) {
|
if (doNotFree) {
|
||||||
doNotFree = false;
|
doNotFree = false;
|
||||||
} else {
|
} else {
|
||||||
PlatformDependent.freeDirectBuffer(oldBuffer);
|
freeDirect(oldBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +502,7 @@ public class UnpooledUnsafeDirectByteBuf extends AbstractReferenceCountedByteBuf
|
|||||||
this.buffer = null;
|
this.buffer = null;
|
||||||
|
|
||||||
if (!doNotFree) {
|
if (!doNotFree) {
|
||||||
PlatformDependent.freeDirectBuffer(buffer);
|
freeDirect(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leak != null) {
|
if (leak != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user