private void tryWriteBytes() throws IOException { lock.lock(); try { // Iterate through the outbound ByteBuff queue, pushing as much as possible into the OS' network buffer. Iterator<ByteBuffer> bytesIterator = bytesToWrite.iterator(); while (bytesIterator.hasNext()) { ByteBuffer buff = bytesIterator.next(); bytesToWriteRemaining -= channel.write(buff); if (!buff.hasRemaining()) bytesIterator.remove(); else { setWriteOps(); break; } } // If we are done writing, clear the OP_WRITE interestOps if (bytesToWrite.isEmpty()) key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE); // Don't bother waking up the selector here, since we're just removing an op, not adding } finally { lock.unlock(); } }
private void tryWriteBytes() throws IOException { lock.lock(); try { // Iterate through the outbound ByteBuff queue, pushing as much as possible into the OS' network buffer. Iterator<ByteBuffer> bytesIterator = bytesToWrite.iterator(); while (bytesIterator.hasNext()) { ByteBuffer buff = bytesIterator.next(); bytesToWriteRemaining -= channel.write(buff); if (!buff.hasRemaining()) bytesIterator.remove(); else { setWriteOps(); break; } } // If we are done writing, clear the OP_WRITE interestOps if (bytesToWrite.isEmpty()) key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE); // Don't bother waking up the selector here, since we're just removing an op, not adding } finally { lock.unlock(); } }
private void tryWriteBytes() throws IOException { lock.lock(); try { // Iterate through the outbound ByteBuff queue, pushing as much as possible into the OS' network buffer. Iterator<ByteBuffer> bytesIterator = bytesToWrite.iterator(); while (bytesIterator.hasNext()) { ByteBuffer buff = bytesIterator.next(); bytesToWriteRemaining -= channel.write(buff); if (!buff.hasRemaining()) bytesIterator.remove(); else { setWriteOps(); break; } } // If we are done writing, clear the OP_WRITE interestOps if (bytesToWrite.isEmpty()) key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE); // Don't bother waking up the selector here, since we're just removing an op, not adding } finally { lock.unlock(); } }
private void tryWriteBytes() throws IOException { lock.lock(); try { // Iterate through the outbound ByteBuff queue, pushing as much as possible into the OS' network buffer. Iterator<ByteBuffer> bytesIterator = bytesToWrite.iterator(); while (bytesIterator.hasNext()) { ByteBuffer buff = bytesIterator.next(); bytesToWriteRemaining -= channel.write(buff); if (!buff.hasRemaining()) bytesIterator.remove(); else { setWriteOps(); break; } } // If we are done writing, clear the OP_WRITE interestOps if (bytesToWrite.isEmpty()) key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE); // Don't bother waking up the selector here, since we're just removing an op, not adding } finally { lock.unlock(); } }
setWriteOps(); } catch (IOException e) { lock.unlock();
setWriteOps(); } catch (IOException e) { lock.unlock();
setWriteOps(); } catch (IOException e) { lock.unlock();
setWriteOps(); } catch (IOException e) { lock.unlock();