Thursday, 15 April 2010

Netty lags for a few seconds before shutting down -


After

Fourths are network programming for a while and recently one of their projects for netty has been changed. . Iv the fact that unlike with its original program, the client will freeze for 3-5 seconds before closing, after I force it to finish every end because I do not want to wait for it to be enough by a lot Bothered Is this normal for nati? Am I doing something wrong?

Main method:

[static void] throws exceptions {Last SSLContext sslCtx = SslContext.newClientContext (InsecureTrustManagerFactory.INSTANCE); EventLoopGroup Group = New NioEventLoopGroup (); Try {bootstrap b = new bootstrap (); B.group (group) .channel (NioSocketChannel.class) .handler (New Network Initializer (sslCtx)); // Start the connection attempt Ch = b.connect (HOST, PORT) .sync (). Channel (); // Client name server asks (); // Loop updates just a few simple GL stuff and gameplay, while running down (running) {loop (); If (Display.isCloseRequested ()) {running = false; If (last quote! = Null) {lastWriteFuture.sync (); } // to write the server down ("9"); Ch.closeFuture () sync () .; Group.shutdownGracefully (); System.out.println ("Hero Fear"); break; }}} Finally {group.shutdownGracefully (); // Connection to shutdown is automatically turned off. }}

Loop class:

  Private static zero loop () {GL11.glClear (GL11.GL_COLOR_BUFFER_BIT); // calculates the main update method for your game and stuff I can post it if Necery but its slightly larger SpaceState.update (); Display.update (); Display.sync (60); }  

group.shutdownGracefully (); Wait by default for about 3 seconds until all pending actions are fully executed, before it ends itself. You can specify a different timeout value, but the risk of being too small value is RejectedExecutionException . If you are certain that no business is left with an event loop group in your application, then you can specify very low values ​​to end it immediately.


No comments:

Post a Comment