Package java.nio.channels

Examples of java.nio.channels.SelectableChannel.keyFor()


   * @param cancellations
   */
  private void process_clear_interest_request(Interest interest) {

    SelectableChannel ch = interest.ch;
    SelectionKey key = ch.keyFor(selector);
    NIOHandler handler = interest.handler;

    if (key == null || !key.isValid()) {
     
      // TODO: maybe this should be considered an error?
View Full Code Here


   * @param remove
   * @param active2
   */
  private void process_add_interest_request(Interest interest) {
    SelectableChannel ch = interest.ch;
    SelectionKey key = ch.keyFor(selector);
    NIOChannelInfo info = null;
   
    if (key != null && !key.isValid()) {
      try {
        selector.selectNow();
View Full Code Here

                key.oldInterestOps = key.interestOps();
                boolean isReadableChannel = ((SelectionKey.OP_ACCEPT | SelectionKey.OP_READ) & key.oldInterestOps) != 0;
                boolean isWritableChannel = ((SelectionKey.OP_CONNECT | SelectionKey.OP_WRITE) & key.oldInterestOps) != 0;
                SelectableChannel channel = key.channel();                 
                if (isReadableChannel) {
                    readChannelList.add(channel.keyFor(this));
                    readableFDs.add(((FileDescriptorHandler)channel).getFD());
                }
                if (isWritableChannel) {
                    writeChannelList.add(channel.keyFor(this));
                    writableFDs.add(((FileDescriptorHandler)channel).getFD());
View Full Code Here

                if (isReadableChannel) {
                    readChannelList.add(channel.keyFor(this));
                    readableFDs.add(((FileDescriptorHandler)channel).getFD());
                }
                if (isWritableChannel) {
                    writeChannelList.add(channel.keyFor(this));
                    writableFDs.add(((FileDescriptorHandler)channel).getFD());
                }
            }
        }
        readableChannels = readChannelList.toArray(new SelectionKey[readChannelList.size()]);
View Full Code Here

            attachment.writing = false;

        SelectableChannel[] channels = handler.getChannels();
        for (int i = 0; i < channels.length; i++) {
            SelectableChannel channel = channels[i];
            SelectionKey key = channel.keyFor(selector);
            if (key != null)
                key.interestOps(key.interestOps()
                        | (channel.validOps() & interest.ops));
        }
    }
View Full Code Here

                key.oldInterestOps = key.interestOps();
                boolean isReadableChannel = ((SelectionKey.OP_ACCEPT | SelectionKey.OP_READ) & key.oldInterestOps) != 0;
                boolean isWritableChannel = ((SelectionKey.OP_CONNECT | SelectionKey.OP_WRITE) & key.oldInterestOps) != 0;
                SelectableChannel channel = key.channel();                 
                if (isReadableChannel) {
                    readChannelList.add(channel.keyFor(this));
                    readableFDs.add(((FileDescriptorHandler)channel).getFD());
                }
                if (isWritableChannel) {
                    writeChannelList.add(channel.keyFor(this));
                    writableFDs.add(((FileDescriptorHandler)channel).getFD());
View Full Code Here

                if (isReadableChannel) {
                    readChannelList.add(channel.keyFor(this));
                    readableFDs.add(((FileDescriptorHandler)channel).getFD());
                }
                if (isWritableChannel) {
                    writeChannelList.add(channel.keyFor(this));
                    writableFDs.add(((FileDescriptorHandler)channel).getFD());
                }
            }
        }
        readableChannels = readChannelList.toArray(new SelectionKey[0]);
View Full Code Here

                key.oldInterestOps = key.interestOps();
                boolean isReadableChannel = ((SelectionKey.OP_ACCEPT | SelectionKey.OP_READ) & key.oldInterestOps) != 0;
                boolean isWritableChannel = ((SelectionKey.OP_CONNECT | SelectionKey.OP_WRITE) & key.oldInterestOps) != 0;
                SelectableChannel channel = key.channel();                 
                if (isReadableChannel) {
                    readChannelList.add(channel.keyFor(this));
                    readableFDs.add(((FileDescriptorHandler)channel).getFD());
                }
                if (isWritableChannel) {
                    writeChannelList.add(channel.keyFor(this));
                    writableFDs.add(((FileDescriptorHandler)channel).getFD());
View Full Code Here

                if (isReadableChannel) {
                    readChannelList.add(channel.keyFor(this));
                    readableFDs.add(((FileDescriptorHandler)channel).getFD());
                }
                if (isWritableChannel) {
                    writeChannelList.add(channel.keyFor(this));
                    writableFDs.add(((FileDescriptorHandler)channel).getFD());
                }
            }
        }
        readableChannels = readChannelList.toArray(new SelectionKey[0]);
View Full Code Here

            if(!(rawChannel instanceof SelectableChannel)) {
                throw runtime.newArgumentError("not a selectable IO object");
            }

            SelectableChannel channel = (SelectableChannel)rawChannel;
            SelectionKey key = channel.keyFor(this.selector);

            if(key == null)
                return context.nil;

            Monitor monitor = (Monitor)key.attachment();
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.