Skip to content

Instantly share code, notes, and snippets.

@GloryAlex
Last active December 9, 2022 13:47
Show Gist options
  • Save GloryAlex/632b0506f24784c83f19e5ade7c7ba78 to your computer and use it in GitHub Desktop.
Save GloryAlex/632b0506f24784c83f19e5ade7c7ba78 to your computer and use it in GitHub Desktop.
Mac OS不提供epoll方法,本机测试的话用kqueue
final boolean isMac =
System.getProperty("os.name").toLowerCase(Locale.US).contains("mac");
// Configure the server.
// See https://netty.io/wiki/native-transports.html
EventLoopGroup bossGroup;
EventLoopGroup workerGroup;
if (isMac) {
bossGroup = new io.netty.channel.kqueue.KQueueEventLoopGroup();
workerGroup = new io.netty.channel.kqueue.KQueueEventLoopGroup(5);
} else {
bossGroup = new io.netty.channel.epoll.EpollEventLoopGroup();
workerGroup = new io.netty.channel.epoll.EpollEventLoopGroup(5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment