Code example for SelectionKey

Methods: interestOps, isValid

0
        return mCompletedCallback;
    } 
 
    @Override 
    public boolean isOpen() { 
        return mChannel.isConnected() && mKey.isValid();
    } 
     
    boolean mPaused = false;
    @Override 
    public void pause() { 
        if (mServer.getAffinity() != Thread.currentThread()) {
            mServer.run(new Runnable() {
                @Override 
                public void run() { 
                    pause(); 
                } 
            }); 
            return; 
        } 
         
        if (mPaused)
            return; 
        mPaused = true;
        try { 
            mKey.interestOps(~SelectionKey.OP_READ & mKey.interestOps());
        } 
        catch (Exception ex) {
        } 
    } 
     
    private void spitPending() { 
        if (pending != null) {
            Util.emitAllData(this, pending);
            if (pending.remaining() == 0) {
                pending = null;
            } 
        } 
    } 
     
    @Override 
    public void resume() { 
        if (mServer.getAffinity() != Thread.currentThread()) {
            mServer.run(new Runnable() {
                @Override 
                public void run() { 
                    resume(); 
                } 
            }); 
            return; 
        } 
         
        if (!mPaused)
            return; 
        mPaused = false;
        try { 
            mKey.interestOps(SelectionKey.OP_READ | mKey.interestOps());
        } 
        catch (Exception ex) {
        } 
        spitPending(); 
        if (!isOpen())