Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding option for custom executor #386

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/com/corundumstudio/socketio/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executor;

import com.corundumstudio.socketio.handler.SuccessAuthorizationListener;
import com.corundumstudio.socketio.listener.DefaultExceptionListener;
Expand Down Expand Up @@ -82,6 +83,8 @@ public class Configuration {

private boolean websocketCompression = true;

private Executor executor = null;

public Configuration() {
}

Expand Down Expand Up @@ -146,6 +149,8 @@ public Configuration() {

setHttpCompression(conf.isHttpCompression());
setWebsocketCompression(conf.isWebsocketCompression());

setExecutor(conf.getExecutor());
}

public JsonSupport getJsonSupport() {
Expand Down Expand Up @@ -561,4 +566,11 @@ public boolean isWebsocketCompression() {
return websocketCompression;
}

public Executor getExecutor() {
return executor;
}

public void setExecutor(Executor executor) {
this.executor = executor;
}
}
38 changes: 19 additions & 19 deletions src/main/java/com/corundumstudio/socketio/SocketIOServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
*/
package com.corundumstudio.socketio;

import com.corundumstudio.socketio.listener.ClientListeners;
import com.corundumstudio.socketio.listener.ConnectListener;
import com.corundumstudio.socketio.listener.DataListener;
import com.corundumstudio.socketio.listener.DisconnectListener;
import com.corundumstudio.socketio.listener.MultiTypeEventListener;
import com.corundumstudio.socketio.namespace.Namespace;
import com.corundumstudio.socketio.namespace.NamespacesHub;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.UUID;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
Expand All @@ -27,21 +42,6 @@
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;

import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.UUID;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.corundumstudio.socketio.listener.ClientListeners;
import com.corundumstudio.socketio.listener.ConnectListener;
import com.corundumstudio.socketio.listener.DataListener;
import com.corundumstudio.socketio.listener.DisconnectListener;
import com.corundumstudio.socketio.listener.MultiTypeEventListener;
import com.corundumstudio.socketio.namespace.Namespace;
import com.corundumstudio.socketio.namespace.NamespacesHub;

/**
* Fully thread-safe.
*
Expand Down Expand Up @@ -179,11 +179,11 @@ protected void applyConnectionOptions(ServerBootstrap bootstrap) {

protected void initGroups() {
if (configCopy.isUseLinuxNativeEpoll()) {
bossGroup = new EpollEventLoopGroup(configCopy.getBossThreads());
workerGroup = new EpollEventLoopGroup(configCopy.getWorkerThreads());
bossGroup = new EpollEventLoopGroup(configCopy.getBossThreads(), configCopy.getExecutor());
workerGroup = new EpollEventLoopGroup(configCopy.getWorkerThreads(), configCopy.getExecutor());
} else {
bossGroup = new NioEventLoopGroup(configCopy.getBossThreads());
workerGroup = new NioEventLoopGroup(configCopy.getWorkerThreads());
bossGroup = new NioEventLoopGroup(configCopy.getBossThreads(), configCopy.getExecutor());
workerGroup = new NioEventLoopGroup(configCopy.getWorkerThreads(), configCopy.getExecutor());
}
}

Expand Down