DefaultEpollIoRegistration Class — netty Architecture
Architecture documentation for the DefaultEpollIoRegistration class in EpollIoHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 7c12c50f_2a4c_ec3b_14e7_2e5cd5f0b5b1["DefaultEpollIoRegistration"] d4f478e3_4aea_ff0a_1e7e_41b7850e2278["EpollIoHandler.java"] 7c12c50f_2a4c_ec3b_14e7_2e5cd5f0b5b1 -->|defined in| d4f478e3_4aea_ff0a_1e7e_41b7850e2278 91c558da_4f14_91c3_d40d_83c24a9c6f9f["DefaultEpollIoRegistration()"] 7c12c50f_2a4c_ec3b_14e7_2e5cd5f0b5b1 -->|method| 91c558da_4f14_91c3_d40d_83c24a9c6f9f 798e65b5_9a9b_c5fe_a73d_39ad92f02d3f["T()"] 7c12c50f_2a4c_ec3b_14e7_2e5cd5f0b5b1 -->|method| 798e65b5_9a9b_c5fe_a73d_39ad92f02d3f dae3d017_be17_f31c_5182_d2d74dfedb54["submit()"] 7c12c50f_2a4c_ec3b_14e7_2e5cd5f0b5b1 -->|method| dae3d017_be17_f31c_5182_d2d74dfedb54 0426876f_cf70_aa35_5c7a_378f7b887062["isValid()"] 7c12c50f_2a4c_ec3b_14e7_2e5cd5f0b5b1 -->|method| 0426876f_cf70_aa35_5c7a_378f7b887062 09b97325_2b5f_bc73_43d1_758f3df9144a["cancel()"] 7c12c50f_2a4c_ec3b_14e7_2e5cd5f0b5b1 -->|method| 09b97325_2b5f_bc73_43d1_758f3df9144a cffd47b3_807b_103a_48bf_61da3bedfc9d["cancel0()"] 7c12c50f_2a4c_ec3b_14e7_2e5cd5f0b5b1 -->|method| cffd47b3_807b_103a_48bf_61da3bedfc9d f412d798_aeaf_139a_c2f5_ba554cb7493a["close()"] 7c12c50f_2a4c_ec3b_14e7_2e5cd5f0b5b1 -->|method| f412d798_aeaf_139a_c2f5_ba554cb7493a a8d55529_65e9_1e0a_675a_0a968a279073["handle()"] 7c12c50f_2a4c_ec3b_14e7_2e5cd5f0b5b1 -->|method| a8d55529_65e9_1e0a_675a_0a968a279073
Relationship Graph
Source Code
transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollIoHandler.java lines 231–319
private final class DefaultEpollIoRegistration implements IoRegistration {
private final ThreadAwareExecutor executor;
private final AtomicBoolean canceled = new AtomicBoolean();
final EpollIoHandle handle;
DefaultEpollIoRegistration(ThreadAwareExecutor executor, EpollIoHandle handle) {
this.executor = executor;
this.handle = handle;
}
@SuppressWarnings("unchecked")
@Override
public <T> T attachment() {
return (T) nativeArrays;
}
@Override
public long submit(IoOps ops) {
EpollIoOps epollIoOps = cast(ops);
try {
if (!isValid()) {
return -1;
}
Native.epollCtlMod(epollFd.intValue(), handle.fd().intValue(), epollIoOps.value);
return epollIoOps.value;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
@Override
public boolean isValid() {
return !canceled.get();
}
@Override
public boolean cancel() {
if (!canceled.compareAndSet(false, true)) {
return false;
}
if (executor.isExecutorThread(Thread.currentThread())) {
cancel0();
} else {
executor.execute(this::cancel0);
}
return true;
}
private void cancel0() {
int fd = handle.fd().intValue();
DefaultEpollIoRegistration old = registrations.remove(fd);
if (old != null) {
if (old != this) {
// The Channel mapping was already replaced due FD reuse, put back the stored Channel.
registrations.put(fd, old);
return;
} else if (old.handle instanceof AbstractEpollChannel.AbstractEpollUnsafe) {
numChannels--;
}
if (handle.fd().isOpen()) {
try {
// Remove the fd registration from epoll. This is only needed if it's still open as otherwise
// it will be automatically removed once the file-descriptor is closed.
Native.epollCtlDel(epollFd.intValue(), fd);
} catch (IOException e) {
logger.debug("Unable to remove fd {} from epoll {}", fd, epollFd.intValue());
}
}
handle.unregistered();
}
}
void close() {
try {
cancel();
} catch (Exception e) {
logger.debug("Exception during canceling " + this, e);
}
try {
handle.close();
} catch (Exception e) {
Source
Frequently Asked Questions
What is the DefaultEpollIoRegistration class?
DefaultEpollIoRegistration is a class in the netty codebase, defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollIoHandler.java.
Where is DefaultEpollIoRegistration defined?
DefaultEpollIoRegistration is defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollIoHandler.java at line 231.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free