Skip to content

Commit

Permalink
Netty 4.2.0.Alpha5
Browse files Browse the repository at this point in the history
  • Loading branch information
astei committed Oct 12, 2024
1 parent 623415e commit ae12c47
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ configurate3 = "3.7.3"
configurate4 = "4.1.2"
flare = "2.0.1"
log4j = "2.22.1"
netty = "4.2.0.Alpha4"
netty = "4.2.0.Alpha5"

[plugins]
indra-publishing = "net.kyori.indra.publishing:2.0.6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import io.netty.channel.uring.IoUringServerSocketChannel;
import io.netty.channel.uring.IoUringSocketChannel;
import java.util.concurrent.ThreadFactory;
import java.util.function.Supplier;

/**
* Enumerates the supported transports for Velocity.
Expand All @@ -53,44 +54,55 @@ public enum TransportType {
NIO("NIO", NioServerSocketChannel::new,
NioSocketChannel::new,
NioDatagramChannel::new,
NioIoHandler.newFactory()),
NioIoHandler::newFactory),
EPOLL("epoll", EpollServerSocketChannel::new,
EpollSocketChannel::new,
EpollDatagramChannel::new,
EpollIoHandler.newFactory()),
EpollIoHandler::newFactory),
KQUEUE("kqueue", KQueueServerSocketChannel::new,
KQueueSocketChannel::new,
KQueueDatagramChannel::new,
KQueueIoHandler.newFactory()),
KQueueIoHandler::newFactory),
IO_URING("io_uring", IoUringServerSocketChannel::new,
IoUringSocketChannel::new,
IoUringDatagramChannel::new,
IoUringIoHandler.newFactory());
IoUringIoHandler::newFactory);

final String name;
final ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory;
final ChannelFactory<? extends SocketChannel> socketChannelFactory;
final ChannelFactory<? extends DatagramChannel> datagramChannelFactory;
final IoHandlerFactory ioHandlerFactory;
final Supplier<IoHandlerFactory> ioHandlerFactorySupplier;
volatile IoHandlerFactory ioHandlerFactory;

TransportType(final String name,
final ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory,
final ChannelFactory<? extends SocketChannel> socketChannelFactory,
final ChannelFactory<? extends DatagramChannel> datagramChannelFactory,
final IoHandlerFactory ioHandlerFactory) {
final Supplier<IoHandlerFactory> ioHandlerFactorySupplier) {
this.name = name;
this.serverSocketChannelFactory = serverSocketChannelFactory;
this.socketChannelFactory = socketChannelFactory;
this.datagramChannelFactory = datagramChannelFactory;
this.ioHandlerFactory = ioHandlerFactory;
this.ioHandlerFactorySupplier = ioHandlerFactorySupplier;
}

@Override
public String toString() {
return this.name;
}

/**
* Creates a new event loop group for the given type.
*
* @param type the type of event loop group to create
* @return the event loop group
*/
public EventLoopGroup createEventLoopGroup(final Type type) {
if (this.ioHandlerFactory == null) {
this.ioHandlerFactory = this.ioHandlerFactorySupplier.get();
}
assert this.ioHandlerFactory != null;
return new MultiThreadIoEventLoopGroup(
0, createThreadFactory(this.name, type), this.ioHandlerFactory);
}
Expand Down

0 comments on commit ae12c47

Please sign in to comment.