EpollEventArray Class — netty Architecture
Architecture documentation for the EpollEventArray class in EpollEventArray.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD db2d0c9c_9d0d_4140_7bf8_37125c131269["EpollEventArray"] 2f0fbc4f_1648_fdde_b749_4596e76d1d5b["EpollEventArray.java"] db2d0c9c_9d0d_4140_7bf8_37125c131269 -->|defined in| 2f0fbc4f_1648_fdde_b749_4596e76d1d5b 46c0b569_c1bc_b0dd_8de4_acd4ce89b62e["EpollEventArray()"] db2d0c9c_9d0d_4140_7bf8_37125c131269 -->|method| 46c0b569_c1bc_b0dd_8de4_acd4ce89b62e 1ef53f22_32bb_7d3e_3732_741b90fefc4b["memoryAddress()"] db2d0c9c_9d0d_4140_7bf8_37125c131269 -->|method| 1ef53f22_32bb_7d3e_3732_741b90fefc4b 629796e1_eeaa_949f_e93e_1e0cf538f0a4["length()"] db2d0c9c_9d0d_4140_7bf8_37125c131269 -->|method| 629796e1_eeaa_949f_e93e_1e0cf538f0a4 9af148c1_d81e_aba3_e0de_0026b23529ca["increase()"] db2d0c9c_9d0d_4140_7bf8_37125c131269 -->|method| 9af148c1_d81e_aba3_e0de_0026b23529ca 4b2154b2_9ef8_095d_fa4e_4487fdbf0ae0["free()"] db2d0c9c_9d0d_4140_7bf8_37125c131269 -->|method| 4b2154b2_9ef8_095d_fa4e_4487fdbf0ae0 80641ba8_de7b_407c_1297_3534dce44ff9["events()"] db2d0c9c_9d0d_4140_7bf8_37125c131269 -->|method| 80641ba8_de7b_407c_1297_3534dce44ff9 6d33aa1f_44ca_c4b1_323d_57714a803600["fd()"] db2d0c9c_9d0d_4140_7bf8_37125c131269 -->|method| 6d33aa1f_44ca_c4b1_323d_57714a803600 073f69f0_5e47_5ce7_dfc0_684c440d9f9a["getInt()"] db2d0c9c_9d0d_4140_7bf8_37125c131269 -->|method| 073f69f0_5e47_5ce7_dfc0_684c440d9f9a c5d5b9db_208b_87a0_2625_ee8426f9e936["calculateBufferCapacity()"] db2d0c9c_9d0d_4140_7bf8_37125c131269 -->|method| c5d5b9db_208b_87a0_2625_ee8426f9e936
Relationship Graph
Source Code
transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollEventArray.java lines 43–127
@UnstableApi
public final class EpollEventArray {
// Size of the epoll_event struct
private static final int EPOLL_EVENT_SIZE = Native.sizeofEpollEvent();
// The offset of the data union in the epoll_event struct
private static final int EPOLL_DATA_OFFSET = Native.offsetofEpollData();
private CleanableDirectBuffer cleanable;
private ByteBuffer memory;
private long memoryAddress;
private int length;
EpollEventArray(int length) {
if (length < 1) {
throw new IllegalArgumentException("length must be >= 1 but was " + length);
}
this.length = length;
cleanable = Buffer.allocateDirectBufferWithNativeOrder(calculateBufferCapacity(length));
memory = cleanable.buffer();
memoryAddress = Buffer.memoryAddress(memory);
}
/**
* Return the {@code memoryAddress} which points to the start of this {@link EpollEventArray}.
*/
long memoryAddress() {
return memoryAddress;
}
/**
* Return the length of the {@link EpollEventArray} which represent the maximum number of {@code epoll_events}
* that can be stored in it.
*/
int length() {
return length;
}
/**
* Increase the storage of this {@link EpollEventArray}.
*/
void increase() {
// double the size
length <<= 1;
// There is no need to preserve what was in the memory before.
CleanableDirectBuffer buffer = Buffer.allocateDirectBufferWithNativeOrder(calculateBufferCapacity(length));
cleanable.clean();
cleanable = buffer;
memory = buffer.buffer();
memoryAddress = Buffer.memoryAddress(buffer.buffer());
}
/**
* Free this {@link EpollEventArray}. Any usage after calling this method may segfault the JVM!
*/
void free() {
cleanable.clean();
memoryAddress = 0;
}
/**
* Return the events for the {@code epoll_event} on this index.
*/
int events(int index) {
return getInt(index, 0);
}
/**
* Return the file descriptor for the {@code epoll_event} on this index.
*/
int fd(int index) {
return getInt(index, EPOLL_DATA_OFFSET);
}
private int getInt(int index, int offset) {
if (PlatformDependent.hasUnsafe()) {
long n = (long) index * EPOLL_EVENT_SIZE;
return PlatformDependent.getInt(memoryAddress + n + offset);
}
return memory.getInt(index * EPOLL_EVENT_SIZE + offset);
}
Source
Frequently Asked Questions
What is the EpollEventArray class?
EpollEventArray is a class in the netty codebase, defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollEventArray.java.
Where is EpollEventArray defined?
EpollEventArray is defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollEventArray.java at line 43.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free