@Override public Thread newThread(Runnable r) { final Thread newThread = new DefaultWorkerThread( AttributeBuilder.DEFAULT_ATTRIBUTE_BUILDER, serverConfig.getName() + "-" + threadCounter.getAndIncrement(), null, r); newThread.setDaemon(true); return newThread; } });
/** * Get thread associated buffer pool. * * @return thread associated buffer pool. This method may return * <code>null</code> if the current thread doesn't have a buffer pool * associated with it. */ protected static ThreadLocalPool getThreadLocalPool() { final Thread t = Thread.currentThread(); if (t instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) t).getMemoryPool(); } else { return null; } }
public static <E> boolean putToCache(final Thread currentThread, final CachedTypeIndex<E> index, final E o) { if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).putToCache(index, o); } else { ObjectCache genericCache = genericCacheAttr.get(); if (genericCache == null) { genericCache = new ObjectCache(); genericCacheAttr.set(genericCache); } return genericCache.put(index, o); } }
/** * Take the cached object with the given type index from cache. * Unlike {@link #getFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object will be removed from cache. * * @param <E> * @param currentThread current {@link Thread} * @param index the cached object type index * @return cached object */ public static <E> E takeFromCache(final Thread currentThread, final CachedTypeIndex<E> index) { if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).takeFromCache(index); } else { final ObjectCache genericCache = genericCacheAttr.get(); if (genericCache != null) { return genericCache.take(index); } return null; } }
/** * Get the cached object with the given type index from cache. * Unlike {@link #takeFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object won't be removed from cache. * * @param <E> * @param currentThread current {@link Thread} * @param index the cached object type index. * @return cached object. */ public static <E> E getFromCache(final Thread currentThread, final CachedTypeIndex<E> index) { assert currentThread == Thread.currentThread(); if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).getFromCache(index); } else { final ObjectCache genericCache = genericCacheAttr.get(); if (genericCache != null) { return genericCache.get(index); } return null; } }
public static <E> boolean putToCache(final Thread currentThread, final CachedTypeIndex<E> index, final E o) { if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).putToCache(index, o); } else { ObjectCache genericCache = genericCacheAttr.get(); if (genericCache == null) { genericCache = new ObjectCache(); genericCacheAttr.set(genericCache); } return genericCache.put(index, o); } }
/** * Take the cached object with the given type index from cache. * Unlike {@link #getFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object will be removed from cache. * * @param <E> * @param currentThread current {@link Thread} * @param index the cached object type index * @return cached object */ public static <E> E takeFromCache(final Thread currentThread, final CachedTypeIndex<E> index) { if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).takeFromCache(index); } else { final ObjectCache genericCache = genericCacheAttr.get(); if (genericCache != null) { return genericCache.take(index); } return null; } }
/** * Get the cached object with the given type index from cache. * Unlike {@link #takeFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object won't be removed from cache. * * @param <E> * @param currentThread current {@link Thread} * @param index the cached object type index. * @return cached object. */ public static <E> E getFromCache(final Thread currentThread, final CachedTypeIndex<E> index) { assert currentThread == Thread.currentThread(); if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).getFromCache(index); } else { final ObjectCache genericCache = genericCacheAttr.get(); if (genericCache != null) { return genericCache.get(index); } return null; } }
@Override public Thread newThread(Runnable r) { final Thread newThread = new DefaultWorkerThread( AttributeBuilder.DEFAULT_ATTRIBUTE_BUILDER, serverConfig.getName() + "-" + threadCounter.getAndIncrement(), null, r); newThread.setDaemon(true); return newThread; } });
public static <E> boolean putToCache(final Thread currentThread, final CachedTypeIndex<E> index, final E o) { if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).putToCache(index, o); } else { ObjectCache genericCache = genericCacheAttr.get(); if (genericCache == null) { genericCache = new ObjectCache(); genericCacheAttr.set(genericCache); } return genericCache.put(index, o); } }
/** * Get thread associated buffer pool. * * @return thread associated buffer pool. This method may return * <code>null</code> if the current thread doesn't have a buffer pool * associated with it. */ protected static ThreadLocalPool getThreadLocalPool() { final Thread t = Thread.currentThread(); if (t instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) t).getMemoryPool(); } else { return null; } }
/** * Take the cached object with the given type index from cache. * Unlike {@link #getFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object will be removed from cache. * * @param <E> * @param currentThread current {@link Thread} * @param index the cached object type index * @return cached object */ public static <E> E takeFromCache(final Thread currentThread, final CachedTypeIndex<E> index) { if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).takeFromCache(index); } else { final ObjectCache genericCache = genericCacheAttr.get(); if (genericCache != null) { return genericCache.take(index); } return null; } }
/** * Get the cached object with the given type index from cache. * Unlike {@link #takeFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object won't be removed from cache. * * @param <E> * @param currentThread current {@link Thread} * @param index the cached object type index. * @return cached object. */ public static <E> E getFromCache(final Thread currentThread, final CachedTypeIndex<E> index) { assert currentThread == Thread.currentThread(); if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).getFromCache(index); } else { final ObjectCache genericCache = genericCacheAttr.get(); if (genericCache != null) { return genericCache.get(index); } return null; } }
@Override public Thread newThread(Runnable r) { final Thread newThread = new DefaultWorkerThread( AttributeBuilder.DEFAULT_ATTRIBUTE_BUILDER, serverConfig.getName() + "-" + threadCounter.getAndIncrement(), null, r); newThread.setDaemon(true); return newThread; } });
public static <E> boolean putToCache(final Thread currentThread, final CachedTypeIndex<E> index, final E o) { if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).putToCache(index, o); } else { ObjectCache genericCache = genericCacheAttr.get(); if (genericCache == null) { genericCache = new ObjectCache(); genericCacheAttr.set(genericCache); } return genericCache.put(index, o); } }
/** * Get thread associated buffer pool. * * @return thread associated buffer pool. This method may return * <code>null</code> if the current thread doesn't have a buffer pool * associated with it. */ protected static ThreadLocalPool getThreadLocalPool() { final Thread t = Thread.currentThread(); if (t instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) t).getMemoryPool(); } else { return null; } }
/** * Take the cached object with the given type index from cache. * Unlike {@link #getFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object will be removed from cache. * * @param <E> * @param currentThread current {@link Thread} * @param index the cached object type index * @return cached object */ public static <E> E takeFromCache(final Thread currentThread, final CachedTypeIndex<E> index) { if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).takeFromCache(index); } else { final ObjectCache genericCache = genericCacheAttr.get(); if (genericCache != null) { return genericCache.take(index); } return null; } }
/** * Get the cached object with the given type index from cache. * Unlike {@link #takeFromCache(org.glassfish.grizzly.ThreadCache.CachedTypeIndex)}, the * object won't be removed from cache. * * @param <E> * @param currentThread current {@link Thread} * @param index the cached object type index. * @return cached object. */ public static <E> E getFromCache(final Thread currentThread, final CachedTypeIndex<E> index) { assert currentThread == Thread.currentThread(); if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).getFromCache(index); } else { final ObjectCache genericCache = genericCacheAttr.get(); if (genericCache != null) { return genericCache.get(index); } return null; } }
@Override public Thread newThread(Runnable r) { final Thread newThread = new DefaultWorkerThread( AttributeBuilder.DEFAULT_ATTRIBUTE_BUILDER, serverConfig.getName() + "-" + threadCounter.getAndIncrement(), null, r); newThread.setDaemon(true); return newThread; } });
public static <E> boolean putToCache(final Thread currentThread, final CachedTypeIndex<E> index, final E o) { if (currentThread instanceof DefaultWorkerThread) { return ((DefaultWorkerThread) currentThread).putToCache(index, o); } else { ObjectCache genericCache = genericCacheAttr.get(); if (genericCache == null) { genericCache = new ObjectCache(); genericCacheAttr.set(genericCache); } return genericCache.put(index, o); } }