protected IPromise directWrite ( ByteBuffer buf ) { checkThread ( ) ; if ( myActor == null ) myActor = Actor . current ( ) ; if ( writePromise != null ) throw new RuntimeException ( "concurrent write con:" + chan . isConnected ( ) + " open:" + chan . isOpen ( ) ) ; writePromise = new Promise ( ) ; writingBuffer = buf ; Promise res = writePromise ; try { int written = 0 ; written = chan . write ( buf ) ; if ( written < 0 ) { // TODO:closed writeFinished ( new IOException ( "connection closed" ) ) ; } if ( buf . remaining ( ) > 0 ) { // key.interestOps(SelectionKey.OP_WRITE); } else { writeFinished ( null ) ; } } catch ( Exception e ) { res . reject ( e ) ; FSTUtil . rethrow ( e ) ; } return res ; }
originally for debugging but now used to reschedule ..