Top Inners Fields Constructors Methods
org.glassfish.grizzly

public final Class ThreadCache

extends Object
Class Inheritance
Imports
java.util.Arrays, .HashMap, .Map, org.glassfish.grizzly.threadpool.DefaultWorkerThread

Author
oleksiys

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class

Field Summary

Modifier and TypeField and Description
private static final ThreadLocal<ThreadCache.ObjectCache>
private static int
private static final ThreadCache.ObjectCacheElement[]
private static final Map<String, ThreadCache.CachedTypeIndex<E>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <
cached object type
E
>
E

Returns:

cached object.
getFromCache
(final ThreadCache.CachedTypeIndex<E>
the cached object type index.
index
)

Get the cached object with the given type index from cache.

public static <
cached object type
E
>
E

Returns:

cached object.
getFromCache
(final Thread
current Thread
currentThread
,
final ThreadCache.CachedTypeIndex<E>
the cached object type index.
index
)

Get the cached object with the given type index from cache.

public static synchronized <E> ThreadCache.CachedTypeIndex<E>
obtainIndex(Class<E> clazz, int size)

public static synchronized <E> ThreadCache.CachedTypeIndex<E>
obtainIndex(String name, Class<E> clazz, int size)

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

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

public static <
cached object type
E
>
E

Returns:

cached object
takeFromCache
(final ThreadCache.CachedTypeIndex<E>
the cached object type index
index
)

Take the cached object with the given type index from cache.

public static <
cached object type
E
>
E

Returns:

cached object
takeFromCache
(final Thread
current Thread
currentThread
,
final ThreadCache.CachedTypeIndex<E>
the cached object type index
index
)

Take the cached object with the given type index from cache.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

genericCacheAttrback to summary
private static final ThreadLocal<ThreadCache.ObjectCache> genericCacheAttr
indexCounterback to summary
private static int indexCounter
INITIAL_OBJECT_ARRAYback to summary
private static final ThreadCache.ObjectCacheElement[] INITIAL_OBJECT_ARRAY
typeIndexMapback to summary
private static final Map<String, ThreadCache.CachedTypeIndex<E>> typeIndexMap

Constructor Detail

ThreadCacheback to summary
public ThreadCache()

Method Detail

getFromCacheback to summary
public static <E> E getFromCache(final 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.

Parameters
<E>
cached object type
index:ThreadCache.CachedTypeIndex<E>

the cached object type index.

Returns:E

cached object.

getFromCacheback to summary
public static <E> E getFromCache(final Thread currentThread, final 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.

Parameters
<E>
cached object type
currentThread:Thread

current Thread

index:ThreadCache.CachedTypeIndex<E>

the cached object type index.

Returns:E

cached object.

obtainIndexback to summary
public static synchronized <E> ThreadCache.CachedTypeIndex<E> obtainIndex(Class<E> clazz, int size)
obtainIndexback to summary
public static synchronized <E> ThreadCache.CachedTypeIndex<E> obtainIndex(String name, Class<E> clazz, int size)
Annotations
@SuppressWarnings:unchecked
putToCacheback to summary
public static <E> boolean putToCache(final ThreadCache.CachedTypeIndex<E> index, final E o)
putToCacheback to summary
public static <E> boolean putToCache(final Thread currentThread, final ThreadCache.CachedTypeIndex<E> index, final E o)
takeFromCacheback to summary
public static <E> E takeFromCache(final 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.

Parameters
<E>
cached object type
index:ThreadCache.CachedTypeIndex<E>

the cached object type index

Returns:E

cached object

takeFromCacheback to summary
public static <E> E takeFromCache(final Thread currentThread, final 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.

Parameters
<E>
cached object type
currentThread:Thread

current Thread

index:ThreadCache.CachedTypeIndex<E>

the cached object type index

Returns:E

cached object

org.glassfish.grizzly back to summary

public final Class ThreadCache.CachedTypeIndex<E>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Class<T>
private final int
private final String
private final int

Constructor Summary

AccessConstructor and Description
public
CachedTypeIndex(final int index, final String name, final Class<E> clazz, final int size)

Method Summary

Modifier and TypeMethod and Description
public Class<T>
public int
public String
public int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clazzback to summary
private final Class<T> clazz
indexback to summary
private final int index
nameback to summary
private final String name
sizeback to summary
private final int size

Constructor Detail

CachedTypeIndexback to summary
public CachedTypeIndex(final int index, final String name, final Class<E> clazz, final int size)

Method Detail

getClazzback to summary
public Class<T> getClazz()
getIndexback to summary
public int getIndex()
getNameback to summary
public String getName()
getSizeback to summary
public int getSize()
org.glassfish.grizzly back to summary

public final Class ThreadCache.ObjectCache

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private ThreadCache.ObjectCacheElement[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public <
cached object type
E
>
E

Returns:

cached object.
get
(final ThreadCache.CachedTypeIndex<E>
the cached object type index.
index
)

Get the cached object with the given type index from cache.

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

public <
cached object type
E
>
E

Returns:

cached object.
take
(final ThreadCache.CachedTypeIndex<E>
the cached object type index.
index
)

Take the cached object with the given type index from cache.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

objectCacheElementsback to summary
private ThreadCache.ObjectCacheElement[] objectCacheElements

Constructor Detail

ObjectCacheback to summary
public ObjectCache()

Method Detail

getback to summary
public <E> E get(final ThreadCache.CachedTypeIndex<E> index)

Get the cached object with the given type index from cache. Unlike take(org.glassfish.grizzly.ThreadCache.CachedTypeIndex), the object won't be removed from cache.

Parameters
<E>
cached object type
index:ThreadCache.CachedTypeIndex<E>

the cached object type index.

Returns:E

cached object.

Annotations
@SuppressWarnings:unchecked
putback to summary
public boolean put(final ThreadCache.CachedTypeIndex<E> index, final Object o)
takeback to summary
public <E> E take(final ThreadCache.CachedTypeIndex<E> index)

Take the cached object with the given type index from cache. Unlike get(org.glassfish.grizzly.ThreadCache.CachedTypeIndex), the object will be removed from cache.

Parameters
<E>
cached object type
index:ThreadCache.CachedTypeIndex<E>

the cached object type index.

Returns:E

cached object.

Annotations
@SuppressWarnings:unchecked
org.glassfish.grizzly back to summary

public final Class ThreadCache.ObjectCacheElement

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Object[]
private int
private final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

object from cache.
get
()

Get (peek) the object from cache.

public boolean
public Object

Returns:

object from cache.
take
()

Take (poll) the object from cache.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private final Object[] cache
indexback to summary
private int index
sizeback to summary
private final int size

Constructor Detail

ObjectCacheElementback to summary
public ObjectCacheElement(int size)

Method Detail

getback to summary
public Object get()

Get (peek) the object from cache. Unlike take() the object will not be removed from cache.

Returns:Object

object from cache.

putback to summary
public boolean put(Object o)
takeback to summary
public Object take()

Take (poll) the object from cache. Unlike get() the object will be removed from cache.

Returns:Object

object from cache.