Code example for SelectableChannel

Methods: register

0
        } 
    } 
 
    public void registerWritingChannel(SelectableChannel channel, PerfMonMetricGetter worker) throws ClosedChannelException {
        sendSelector.wakeup();
        channel.register(sendSelector, SelectionKey.OP_WRITE, worker);
    } 
 
    private void processSenders() throws IOException { 
        //log.debug("Selecting senders from " + sendSelector.keys().size()); 
        sendSelector.select(getInterval());
        //log.debug("Selected senders " + this.sendSelector.selectedKeys().size()); 
 
        long begin = System.currentTimeMillis();
 
        // wakeup to work on selected keys 
        Iterator keys = this.sendSelector.selectedKeys().iterator();
        while (keys.hasNext()) {
            SelectionKey key = (SelectionKey) keys.next();
 
            keys.remove();