gpt4 book ai didi

com.sun.grizzly.util.WorkerThreadImpl类的使用及代码示例

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

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

WorkerThreadImpl介绍

[英]Simple worker thread used for processing HTTP requests. All threads are synchronized using a Pipeline object
[中]用于处理HTTP请求的简单工作线程。所有线程都使用管道对象进行同步

代码示例

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

/**
   * Creates an instance of WorkerThreadImpl.
   *
   * @param name {@link String}
   * @param initialByteBufferSize initial {@link ByteBuffer} size
   */
  protected WorkerThreadImpl createWorkerThread(String name,
          int initialByteBufferSize) {

    return new WorkerThreadImpl(this, name, initialByteBufferSize);
  }
}

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

@Override
protected void afterExecute(Runnable r, Throwable t) {
  ((WorkerThreadImpl) Thread.currentThread()).reset();
}

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

/**
 * Create a new {@link WorkerThread}.
 * @param r a Runabble
 * @return
 */
public Thread newThread(Runnable r){
  WorkerThreadImpl t = new WorkerThreadImpl(threadGroup, r);
  t.setDaemon(true);
  return t;
}

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

public Thread newThread(Runnable r) {
    WorkerThreadImpl workerThread = new WorkerThreadImpl(threadPool,
        threadPool.name + "WorkerThread-"  + threadPool.port + "-" +
        threadPool.workerThreadCounter.getAndIncrement(), r,
        threadPool.initialByteBufferSize);
    workerThread.setByteBufferType(threadPool.byteBufferType);
    workerThread.setPriority(threadPool.priority);
    return workerThread;
  }
}

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

/**
 * Start using the Controller's internal Thread Pool.
 */
public void start() {
  if (port == 0){
    selectorThreads.put(getSelectorThreadLookupKey(inet, port), this);
  }
  new WorkerThreadImpl("SelectorThread-" + port,this).start();
}

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

public ThreadAttachment detach() {
  ThreadAttachment currentAttachment = getAttachment();
  int mode = currentAttachment.getMode();
  updateAttachment(mode);
  
  // Re-create a new ByteBuffer
  if ((mode & Mode.BYTE_BUFFER) != 0) {
    createByteBuffer(true);
  }
  
  if ((mode & Mode.SSL_ENGINE) != 0) {
    sslEngine = null;
  }
  
  if ((mode & Mode.INPUT_BB) != 0) {
    inputBB = null;
  }
  
  if ((mode & Mode.OUTPUT_BB) != 0) {
    outputBB = null;
  }
  
  // Switch to the new ThreadAttachment.
  this.threadAttachment = null;
  
  currentAttachment.deassociate();
  return currentAttachment;
}

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

public ThreadAttachment detach() {
  ThreadAttachment currentAttachment = getAttachment();
  int mode = currentAttachment.getMode();
  updateAttachment(mode);
  
  // Re-create a new ByteBuffer
  if ((mode & Mode.BYTE_BUFFER) != 0) {
    byteBuffer = null;
  }
  
  if ((mode & Mode.SSL_ENGINE) != 0) {
    sslEngine = null;
  }
  
  if ((mode & Mode.INPUT_BB) != 0) {
    inputBB = null;
  }
  
  if ((mode & Mode.OUTPUT_BB) != 0) {
    outputBB = null;
  }
  
  // Switch to the new ThreadAttachment.
  this.threadAttachment = null;
  
  currentAttachment.deassociate();
  return currentAttachment;
}

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

/**
 * Create new {@link WorkerThreadImpl}. This method must be invoked
 * from a synchronized block.
 * @param increment - how many additional {@link WorkerThreadImpl}
 * objects to add
 * @param startThread - should newly added {@link WorkerThreadImpl}
 * objects be started after creation?
 */
protected void increaseWorkerThread(int increment, boolean startThread){
  WorkerThreadImpl workerThread;
  int currentCount = threadCount;
  int increaseCount = threadCount + increment;
  for (int i=currentCount; i < increaseCount; i++){
    workerThread = createWorkerThread(
        name + "WorkerThread-"  + port + "-" + i,
        initialByteBufferSize);
    workerThread.setByteBufferType(byteBufferType);
    workerThread.setPriority(priority);
    
    if (startThread)
      workerThread.start();
    
    workerThreads[i] = workerThread;
    threadCount++;
  }
}

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

/**
 * Create a Thread that will synchronizes/block on
 * {@link DefaultThreadPool} instance.
 * @param threadGroup <code>ThreadGroup</code>
 * @param runnable <code>Runnable</code>
 * @param initialByteBufferSize initial {@link ByteBuffer} size
 */
public WorkerThreadImpl(ThreadGroup threadGroup, Runnable runnable, 
    int initialByteBufferSize){
  super(threadGroup, runnable);
  setDaemon(true);
  this.initialByteBufferSize = initialByteBufferSize;
}

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

processTask(t);
  t = null;
} catch (Throwable t) {
  reset();

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

public ThreadAttachment updateAttachment(int mode) {
  ThreadAttachment currentAttachment = getAttachment();
  currentAttachment.reset();
  if ((mode & Mode.BYTE_BUFFER) != 0) {
    currentAttachment.setByteBuffer(byteBuffer);
  }
  if ((mode & Mode.SSL_ENGINE) != 0) {
    currentAttachment.setSSLEngine(sslEngine);
  }
  if ((mode & Mode.INPUT_BB) != 0) {
    currentAttachment.setInputBB(inputBB);
  }
  if ((mode & Mode.OUTPUT_BB) != 0) {
    currentAttachment.setOutputBB(outputBB);
  }
  currentAttachment.setMode(mode);
  
  return currentAttachment;
}

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

/**
 * Start the {@link Pipeline} and all associated
 * {@link WorkerThreadImpl}
 */
public synchronized void startPipeline(){
  if (!isStarted) {
    for (int i=0; i < minThreads; i++){
      workerThreads[i].start();
    }
    isStarted = true;
  }
}

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

/**
 * must hold statelock while calling this method.
 * @param wt
 */
protected void startWorker(Worker wt) {
  final Thread thread = threadFactory.newThread(wt);
  thread.setName(getName() + "(" + nextThreadId() + ")");
  thread.setUncaughtExceptionHandler(this);
  thread.setPriority(getPriority());
  thread.setDaemon(true);
  if (thread instanceof WorkerThreadImpl) {
    final WorkerThreadImpl workerThread = (WorkerThreadImpl) thread;
    workerThread.setByteBufferType(getByteBufferType());
    workerThread.setInitialByteBufferSize(getInitialByteBufferSize());
  }
  wt.t = thread;
  workers.put(wt, System.currentTimeMillis());
  wt.t.start();
}

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

@Override
protected void beforeExecute(Thread t, Runnable r) {
  ((WorkerThreadImpl) t).createByteBuffer(false);
}

代码示例来源:origin: org.shoal/shoal-gms-impl

new WorkerThreadImpl("ControllerWorker", controller).start();

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

public ThreadAttachment detach() {
  ThreadAttachment currentAttachment = getAttachment();
  int mode = currentAttachment.getMode();
  updateAttachment(mode);
  
  // Re-create a new ByteBuffer
  if ((mode & Mode.BYTE_BUFFER) != 0) {
    byteBuffer = ByteBufferFactory.allocate(byteBufferType,
        initialByteBufferSize);
  }
  
  if ((mode & Mode.SSL_ENGINE) != 0) {
    sslEngine = null;
  }
  
  if ((mode & Mode.INPUT_BB) != 0) {
    inputBB = null;
  }
  
  if ((mode & Mode.OUTPUT_BB) != 0) {
    outputBB = null;
  }
  
  // Switch to the new ThreadAttachment.
  this.threadAttachment = null;
  
  currentAttachment.deassociate();
  return currentAttachment;
}

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

/**
 * Create a Thread that will synchronizes/block on
 * {@link DefaultThreadPool} instance.
 * @param threadPool {@link DefaultThreadPool}
 * @param name <code>String</code>
 * @param initialByteBufferSize initial {@link ByteBuffer} size
 */
public WorkerThreadImpl(DefaultThreadPool threadPool, String name,
    int initialByteBufferSize){
  super(threadGroup, name);
  this.threadPool = threadPool;
  setDaemon(true);
  this.initialByteBufferSize = initialByteBufferSize;
}

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

public ThreadAttachment updateAttachment(int mode) {
  ThreadAttachment currentAttachment = getAttachment();
  currentAttachment.reset();
  if ((mode & Mode.BYTE_BUFFER) != 0) {
    currentAttachment.setByteBuffer(byteBuffer);
  }
  if ((mode & Mode.SSL_ENGINE) != 0) {
    currentAttachment.setSSLEngine(sslEngine);
  }
  if ((mode & Mode.INPUT_BB) != 0) {
    currentAttachment.setInputBB(inputBB);
  }
  if ((mode & Mode.OUTPUT_BB) != 0) {
    currentAttachment.setOutputBB(outputBB);
  }
  currentAttachment.setMode(mode);
  
  return currentAttachment;
}

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

/**
 * Method invoked prior to executing the given Runnable in the
 * given thread.  This method is invoked by thread <tt>t</tt> that
 * will execute task <tt>r</tt>, and may be used to re-initialize
 * ThreadLocals, or to perform logging.
 *
 * <p>This implementation does nothing, but may be customized in
 * subclasses. Note: To properly nest multiple overridings, subclasses
 * should generally invoke <tt>super.beforeExecute</tt> at the end of
 * this method.
 *
 * @param t the thread that will run task r.
 * @param r the task that will be executed.
 */
protected void beforeExecute(Thread t, Runnable r) {
  if (t instanceof WorkerThreadImpl)
    ((WorkerThreadImpl) t).createByteBuffer(false);
}

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

public Thread newThread(Runnable r) {
      return new WorkerThreadImpl(new ThreadGroup("Grizzly"),r);
    }
});

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