-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9789 from galderz/t_empty_buffer_netty_reset_and_…
…substitute_9750 Move empty byte buffer creation direct buffer to runtime
- Loading branch information
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
extensions/netty/runtime/src/main/java/io/quarkus/netty/runtime/EmptyByteBufStub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.quarkus.netty.runtime; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
import io.netty.util.internal.PlatformDependent; | ||
|
||
public final class EmptyByteBufStub { | ||
private static final ByteBuffer EMPTY_BYTE_BUFFER = ByteBuffer.allocateDirect(0); | ||
private static final long EMPTY_BYTE_BUFFER_ADDRESS; | ||
|
||
static { | ||
long emptyByteBufferAddress = 0; | ||
try { | ||
if (PlatformDependent.hasUnsafe()) { | ||
emptyByteBufferAddress = PlatformDependent.directBufferAddress(EMPTY_BYTE_BUFFER); | ||
} | ||
} catch (Throwable t) { | ||
// Ignore | ||
} | ||
EMPTY_BYTE_BUFFER_ADDRESS = emptyByteBufferAddress; | ||
} | ||
|
||
public static ByteBuffer emptyByteBuffer() { | ||
return EMPTY_BYTE_BUFFER; | ||
} | ||
|
||
public static long emptyByteBufferAddress() { | ||
return EMPTY_BYTE_BUFFER_ADDRESS; | ||
} | ||
|
||
private EmptyByteBufStub() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters