org.glassfish.grizzly.threadpool
Class DefaultWorkerThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.glassfish.grizzly.threadpool.DefaultWorkerThread
All Implemented Interfaces:
java.lang.Runnable, AttributeStorage, WorkerThread

public class DefaultWorkerThread
extends java.lang.Thread
implements WorkerThread

Default Grizzly worker thread implementation

Author:
Alexey Stashok

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface org.glassfish.grizzly.threadpool.WorkerThread
UNLIMITED_TRANSACTION_TIMEOUT
 
Constructor Summary
DefaultWorkerThread(AttributeBuilder attrBuilder, java.lang.String name, ThreadLocalPool pool, java.lang.Runnable runTask)
           
 
Method Summary
 AttributeHolder getAttributes()
          Get associated AttributeHolder.
<E> E
getFromCache(ThreadCache.CachedTypeIndex<E> index)
          Get the cached object with the given type index from cache.
 ThreadLocalPool getMemoryPool()
           
 java.lang.Thread getThread()
           
 long getTransactionTimeout(java.util.concurrent.TimeUnit timeunit)
           
 boolean isSelectorThread()
           
<E> boolean
putToCache(ThreadCache.CachedTypeIndex<E> index, E o)
           
 void setSelectorThread(boolean isSelectorThread)
           
 void setTransactionTimeout(long timeout, java.util.concurrent.TimeUnit timeunit)
           
<E> E
takeFromCache(ThreadCache.CachedTypeIndex<E> index)
          Take the cached object with the given type index from cache.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.glassfish.grizzly.threadpool.WorkerThread
destroy, getName, start, stop
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

DefaultWorkerThread

public DefaultWorkerThread(AttributeBuilder attrBuilder,
                           java.lang.String name,
                           ThreadLocalPool pool,
                           java.lang.Runnable runTask)
Method Detail

getThread

public java.lang.Thread getThread()
Specified by:
getThread in interface WorkerThread

getAttributes

public AttributeHolder getAttributes()
Description copied from interface: AttributeStorage
Get associated AttributeHolder. Implementation may return null if AttributeHolder wasn't initialized yet.

Specified by:
getAttributes in interface AttributeStorage
Returns:
associated AttributeHolder. Implementation may return null if AttributeHolder wasn't initialized yet.

getMemoryPool

public ThreadLocalPool getMemoryPool()

getFromCache

public final <E> E getFromCache(ThreadCache.CachedTypeIndex<E> index)
Get the cached object with the given type index from cache. Unlike takeFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex), the object won't be removed from cache.

Type Parameters:
E -
Parameters:
index - the cached object type index.
Returns:
cached object.

takeFromCache

public final <E> E takeFromCache(ThreadCache.CachedTypeIndex<E> index)
Take the cached object with the given type index from cache. Unlike getFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex), the object will be removed from cache.

Type Parameters:
E -
Parameters:
index - the cached object type index.
Returns:
cached object.

putToCache

public final <E> boolean putToCache(ThreadCache.CachedTypeIndex<E> index,
                                    E o)

getTransactionTimeout

public long getTransactionTimeout(java.util.concurrent.TimeUnit timeunit)
Specified by:
getTransactionTimeout in interface WorkerThread

setTransactionTimeout

public void setTransactionTimeout(long timeout,
                                  java.util.concurrent.TimeUnit timeunit)
Specified by:
setTransactionTimeout in interface WorkerThread

isSelectorThread

public boolean isSelectorThread()
Specified by:
isSelectorThread in interface WorkerThread

setSelectorThread

public void setSelectorThread(boolean isSelectorThread)
Specified by:
setSelectorThread in interface WorkerThread


Copyright © 2011 Oracle Corpration. All Rights Reserved.