コード例 #1
0
 @Override
 public void write(final SerialMsg msg) {
   if (handler.getChannel().isConnected() && handler.getChannel().isOpen()) {
     writeListener.incrementAndGet();
     handler.getChannel().write(msg).addListener(writeListener);
   }
 }
コード例 #2
0
 @Override
 public void operationComplete(final ChannelFuture future) throws Exception {
   if (decrementAndGet() == 0 && handler != null) {
     final CountDownLatch cdl = new CountDownLatch(1);
     handler
         .getChannel()
         .close()
         .addListener(
             new ChannelFutureListener() {
               @Override
               @SuppressWarnings({"AnonymousClassVariableHidesContainingMethodVariable"})
               public void operationComplete(final ChannelFuture future) throws Exception {
                 cdl.countDown();
               }
             });
     try {
       cdl.await();
     } catch (InterruptedException e) { //
       e.printStackTrace();
     }
   }
 }