gpt4 book ai didi

com.sun.grizzly.util.WorkerThread.getAttachment()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 21:51:05 25 4
gpt4 key购买 nike

本文整理了Java中com.sun.grizzly.util.WorkerThread.getAttachment()方法的一些代码示例,展示了WorkerThread.getAttachment()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WorkerThread.getAttachment()方法的具体详情如下:
包路径:com.sun.grizzly.util.WorkerThread
类名称:WorkerThread
方法名:getAttachment

WorkerThread.getAttachment介绍

[英]Get the current set of attributes (state) associated with this instance. Unlike detach(), this method doesn't clear the WorkerThread attributes.
[中]获取与此实例关联的当前属性集(状态)。与detach()不同,此方法不清除WorkerThread属性。

代码示例

代码示例来源:origin: com.sun.grizzly/grizzly-http

private static ThreadAttachment obtainThreadAttachment() {
  final Thread currentThread = Thread.currentThread();
  if (currentThread instanceof WorkerThread) {
    return ((WorkerThread) currentThread).getAttachment();
  }
  return new KeepAliveThreadAttachment();
}

代码示例来源:origin: org.glassfish.external/grizzly-module

private void saveParser(SelectionKey key, ProtocolParser parser) {
  WorkerThread workerThread = (WorkerThread) Thread.currentThread();
  // Detach the current Thread data.
  ThreadAttachment threadAttachment = workerThread.getAttachment();
  threadAttachment.setAttribute(ProtocolParser.PARSER, parser);
  // Attach it to the SelectionKey so the it can be resumed latter.
  key.attach(threadAttachment);
}

代码示例来源:origin: com.sun.grizzly/grizzly-utils

private static ThreadAttachment obtainThreadAttachment() {
  final Thread currentThread = Thread.currentThread();
  if (currentThread instanceof WorkerThread) {
    return ((WorkerThread) currentThread).getAttachment();
  }
  return new ThreadAttachment();
}

代码示例来源:origin: com.sun.grizzly/grizzly-utils

private static void notifyRemotelyClosed(SelectionKey key) {
  if (Thread.currentThread() instanceof WorkerThread) {
    ConnectionCloseHandlerNotifier notifier =
        (ConnectionCloseHandlerNotifier) ((WorkerThread) Thread.currentThread()).getAttachment().getAttribute("ConnectionCloseHandlerNotifier");
    if (notifier != null) {
      notifier.notifyRemotlyClose(key);
    }
  }
}

代码示例来源:origin: com.sun.grizzly/grizzly-http

private KeepAliveThreadAttachment getKeepAliveAttachment() {
  final Thread t = Thread.currentThread();
  if (t instanceof WorkerThread) {
    final WorkerThread workerThread = (WorkerThread) t;
    final KeepAliveThreadAttachment threadAttachment =
        (KeepAliveThreadAttachment) workerThread.getAttachment();
    key.attach(threadAttachment);
    return threadAttachment;
  }
  
  final Object attachment = key.attachment();
  if (attachment != null) {
    return (KeepAliveThreadAttachment) attachment;
  }
  
  final KeepAliveThreadAttachment threadAttachment = new KeepAliveThreadAttachment();
  threadAttachment.associate();
  key.attach(threadAttachment);
  
  return threadAttachment;
  
}

代码示例来源:origin: com.sun.grizzly/grizzly-http-utils

ConnectionCloseHandler cch = (ConnectionCloseHandler)
    ((WorkerThread)Thread.currentThread())
      .getAttachment().getAttribute("ConnectionCloseHandler");
if (cch != null){
  cch.remotlyClosed(key);

代码示例来源:origin: com.sun.grizzly/grizzly-http-utils

ConnectionCloseHandler cch = (ConnectionCloseHandler)
    ((WorkerThread)Thread.currentThread())
      .getAttachment().getAttribute("ConnectionCloseHandler");
if (cch != null){
  cch.remotlyClosed(key);

代码示例来源:origin: com.sun.grizzly/grizzly-http-utils

ConnectionCloseHandler cch = (ConnectionCloseHandler)
    ((WorkerThread)Thread.currentThread())
      .getAttachment().getAttribute("ConnectionCloseHandler");
if (cch != null){
  cch.remotlyClosed(key);

代码示例来源:origin: com.sun.grizzly/grizzly-utils

ConnectionCloseHandlerNotifier notifier = (ConnectionCloseHandlerNotifier)
    ((WorkerThread)Thread.currentThread())
      .getAttachment().getAttribute("ConnectionCloseHandlerNotifier");
if (notifier != null){
  notifier.notifyRemotlyClose(key);

代码示例来源:origin: org.glassfish.external/grizzly-module

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));
  }
}

代码示例来源:origin: org.glassfish.external/grizzly-module

ctx.getSelectionKey().attach(null);
} else {
  wt.getAttachment().setTimeout(null);

代码示例来源:origin: org.glassfish.external/grizzly-module

kh.setKey(key);
WorkerThread workerThread = (WorkerThread) Thread.currentThread();
ThreadAttachment attachment = workerThread.getAttachment();
attachment.setMode(Mode.STORE_ALL);
kh.setThreadAttachment(workerThread.detach());

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com