Examples of attachment()


Examples of java.nio.channels.SelectionKey.attachment()

            } else {
                final SelectionKey key = socket.getIOChannel().keyFor(socket.getPoller().getSelector());
                try {
                    boolean cancel = false;
                    if (key != null) {
                        final KeyAttachment att = (KeyAttachment) key.attachment();
                        if ( att!=null ) {
                            //handle callback flag
                            if ((interestOps & OP_CALLBACK) == OP_CALLBACK ) {
                                att.setCometNotify(true);
                            } else {
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

                        keyCount > 0 ? selector.selectedKeys().iterator() : null;
                    // Walk through the collection of ready keys and dispatch
                    // any active event.
                    while (iterator != null && iterator.hasNext()) {
                        SelectionKey sk = iterator.next();
                        KeyAttachment attachment = (KeyAttachment)sk.attachment();
                        // Attachment may be null if another thread has called
                        // cancelledKey()
                        if (attachment == null) {
                            iterator.remove();
                        } else {
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

            int keycount = 0;
            for (Iterator<SelectionKey> iter = keys.iterator(); iter.hasNext();) {
                SelectionKey key = iter.next();
                keycount++;
                try {
                    KeyAttachment ka = (KeyAttachment) key.attachment();
                    if ( ka == null ) {
                        cancelledKey(key, SocketStatus.ERROR); //we don't support any keys without attachments
                    } else if ( ka.getError() ) {
                        cancelledKey(key, SocketStatus.ERROR);//TODO this is not yet being used
                    } else if (ka.getCometNotify() ) {
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

            SelectionKey key = socket.getIOChannel().keyFor(
                    socket.getPoller().getSelector());
            KeyAttachment ka = null;

            if (key != null) {
                ka = (KeyAttachment)key.attachment();
            }

            // Upgraded connections need to allow multiple threads to access the
            // connection at the same time to enable blocking IO to be used when
            // NIO has been configured
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

      }
     
    } else {
     
      // get channel info
      NIOChannelInfo info = (NIOChannelInfo) key.attachment();
     
      if (info == null) {
        // error!
        throw new InternalError();
      }
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

            info = new NIOChannelInfo(interest));
      } catch (ClosedChannelException e) {
        interest.handler.exception(ch, e);
      }
    } else {
      info = (NIOChannelInfo) key.attachment();
      info.add(interest);
      info.updateInterestOpsFor(key);
    }
   
  }
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

          synchronized (writeSelector.keys()) {
            calls = new ArrayList<Call>(writeSelector.keys().size());
            iter = writeSelector.keys().iterator();
            while (iter.hasNext()) {
              SelectionKey key = iter.next();
              Call call = (Call)key.attachment();
              if (call != null && key.channel() == call.connection.channel) {
                calls.add(call);
              }
            }
          }
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

                nioDaemon.getServer().handleAccept(key, nioDaemon.getSelector());
            }
           
            // an outgoing connection has been established
            if(key.isValid() && key.isConnectable()) {
                NIOAttachment attachment = (NIOAttachment)key.attachment();
                attachment.handleConnect();
            }

            // incoming data can be read
            if(key.isValid() && key.isReadable()) {
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

                attachment.handleConnect();
            }

            // incoming data can be read
            if(key.isValid() && key.isReadable()) {
                NIOAttachment attachment = (NIOAttachment)key.attachment();
                attachment.handleRead();
            }
           
            // outgoing data can be written
            if(key.isValid() && key.isWritable()) {
View Full Code Here

Examples of java.nio.channels.SelectionKey.attachment()

                attachment.handleRead();
            }
           
            // outgoing data can be written
            if(key.isValid() && key.isWritable()) {
                NIOAttachment attachment = (NIOAttachment)key.attachment();
                attachment.handleWrite();
            }

            // clean up broken connections
            if(!key.isValid()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.