mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-23 00:21:26 +01:00
Close the main selector
This commit is contained in:
parent
8895e49a52
commit
0d91f9efc6
@ -24,6 +24,7 @@ public class Server {
|
|||||||
|
|
||||||
private volatile boolean stop;
|
private volatile boolean stop;
|
||||||
|
|
||||||
|
private final Selector selector = Selector.open();
|
||||||
private final List<Worker> workers = new ArrayList<>(WORKER_COUNT);
|
private final List<Worker> workers = new ArrayList<>(WORKER_COUNT);
|
||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
@ -39,7 +40,6 @@ public class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void start(SocketAddress address) throws IOException {
|
public void start(SocketAddress address) throws IOException {
|
||||||
Selector selector = Selector.open();
|
|
||||||
this.serverSocket = ServerSocketChannel.open();
|
this.serverSocket = ServerSocketChannel.open();
|
||||||
serverSocket.bind(address);
|
serverSocket.bind(address);
|
||||||
serverSocket.configureBlocking(false);
|
serverSocket.configureBlocking(false);
|
||||||
@ -65,6 +65,7 @@ public class Server {
|
|||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
this.stop = true;
|
this.stop = true;
|
||||||
|
this.selector.wakeup();
|
||||||
this.workers.forEach(worker -> worker.selector.wakeup());
|
this.workers.forEach(worker -> worker.selector.wakeup());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user