private void saveByteBuffer(SelectionKey key) { WorkerThread workerThread = (WorkerThread) Thread.currentThread(); // Detach the current Thread data. ThreadAttachment threadAttachment = workerThread.updateAttachment(Mode.BYTE_BUFFER); // Attach it to the SelectionKey so the it can be resumed latter. key.attach(threadAttachment); }
private void saveSecuredBufferRemainders(SelectionKey selectionKey) { ThreadAttachment attachment = (ThreadAttachment) selectionKey.attachment(); WorkerThread workerThread = (WorkerThread) Thread.currentThread(); if (attachment == null || workerThread.getAttachment() != attachment) { Controller.logger().log(Level.FINE, "SelectionKey ThreadAttachment is NULL or doesn't " + "correspond to the current thread, when saving buffers"); return; } ByteBuffer inputBB = workerThread.getInputBB(); if (inputBB != null && inputBB.hasRemaining()) { workerThread.updateAttachment(attachment.getMode() | Mode.INPUT_BB); } else { workerThread.updateAttachment(attachment.getMode() & (Integer.MAX_VALUE ^ Mode.INPUT_BB)); } ByteBuffer outputBB = workerThread.getOutputBB(); if (outputBB != null && outputBB.hasRemaining()) { workerThread.updateAttachment(attachment.getMode() | Mode.OUTPUT_BB); } else { workerThread.updateAttachment(attachment.getMode() & (Integer.MAX_VALUE ^ Mode.OUTPUT_BB)); } }
attachment = workerThread.updateAttachment(Mode.SSL_ENGINE); key.attach(attachment);
attachment = workerThread.updateAttachment(Mode.SSL_ENGINE); key.attach(attachment);
workerThread.setOutputBB(outputBB); final Object attachment = workerThread.updateAttachment(Mode.SSL_ENGINE); key.attach(attachment);
sslEngine = newSSLEngine(key); workerThread.setSSLEngine(sslEngine); ThreadAttachment attachment = workerThread.updateAttachment(Mode.SSL_ENGINE); key.attach(attachment);
if (isExpectingMoreData) { ((WorkerThread) Thread.currentThread()).updateAttachment(Mode.ATTRIBUTES_ONLY);