Top Inners Fields Constructors Methods
org.glassfish.grizzly.utils

public Class DelayedExecutor

extends Object
Class Inheritance
Imports
java.util.Iterator, .Queue, java.util.concurrent.ConcurrentHashMap, .ConcurrentLinkedQueue, .ConcurrentMap, .ExecutorService, .TimeUnit

Author
Alexey Stashok

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
public class
public static interface
public static interface

Field Summary

Modifier and TypeField and Description
private final long
private volatile boolean
private final Queue<DelayedExecutor.DelayQueue<E>>
private final DelayedExecutor.DelayedRunnable
private final Object
private final ExecutorService
public static final long

Constructor Summary

AccessConstructor and Description
public
DelayedExecutor(final ExecutorService threadPool)

public
DelayedExecutor(final ExecutorService threadPool, final long checkInterval, final TimeUnit timeunit)

Method Summary

Modifier and TypeMethod and Description
public <E> DelayedExecutor.DelayQueue<E>
createDelayQueue(final DelayedExecutor.Worker<E> worker, final DelayedExecutor.Resolver<E> resolver)

public void
public ExecutorService
public void
public void
stop()

private static boolean
wasModified(final long l1, final long l2)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

checkIntervalMillisback to summary
private final long checkIntervalMillis
isStartedback to summary
private volatile boolean isStarted
queuesback to summary
private final Queue<DelayedExecutor.DelayQueue<E>> queues
runnableback to summary
private final DelayedExecutor.DelayedRunnable runnable
syncback to summary
private final Object sync
threadPoolback to summary
private final ExecutorService threadPool
UNSET_TIMEOUTback to summary
public static final long UNSET_TIMEOUT

Constructor Detail

DelayedExecutorback to summary
public DelayedExecutor(final ExecutorService threadPool)
DelayedExecutorback to summary
public DelayedExecutor(final ExecutorService threadPool, final long checkInterval, final TimeUnit timeunit)

Method Detail

createDelayQueueback to summary
public <E> DelayedExecutor.DelayQueue<E> createDelayQueue(final DelayedExecutor.Worker<E> worker, final DelayedExecutor.Resolver<E> resolver)
destroyback to summary
public void destroy()
getThreadPoolback to summary
public ExecutorService getThreadPool()
Annotations
@SuppressWarnings:UnusedDeclaration
startback to summary
public void start()
stopback to summary
public void stop()
wasModifiedback to summary
private static boolean wasModified(final long l1, final long l2)
org.glassfish.grizzly.utils back to summary

private Class DelayedExecutor.DelayedRunnable

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DelayedRunnableback to summary
private DelayedRunnable()

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

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

public Class DelayedExecutor.DelayQueue<E>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final ConcurrentMap<E, DelayedExecutor.DelayQueue<E>>
pack-priv final DelayedExecutor.Resolver<E>
pack-priv final DelayedExecutor.Worker<E>

Constructor Summary

AccessConstructor and Description
public
DelayQueue(final DelayedExecutor.Worker<E> worker, final DelayedExecutor.Resolver<E> resolver)

Method Summary

Modifier and TypeMethod and Description
public void
add(final E elem, final long delay, final TimeUnit timeUnit)

public void
public void
remove(final E elem)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

queueback to summary
pack-priv final ConcurrentMap<E, DelayedExecutor.DelayQueue<E>> queue
resolverback to summary
pack-priv final DelayedExecutor.Resolver<E> resolver
workerback to summary
pack-priv final DelayedExecutor.Worker<E> worker

Constructor Detail

DelayQueueback to summary
public DelayQueue(final DelayedExecutor.Worker<E> worker, final DelayedExecutor.Resolver<E> resolver)

Method Detail

addback to summary
public void add(final E elem, final long delay, final TimeUnit timeUnit)
destroyback to summary
public void destroy()
removeback to summary
public void remove(final E elem)
org.glassfish.grizzly.utils back to summary

public Interface DelayedExecutor.Resolver<E>

Known Direct Implementers
org.glassfish.grizzly.utils.IdleTimeoutFilter.Resolver, org.glassfish.grizzly.utils.SilentConnectionFilter.Resolver, org.glassfish.grizzly.utils.ActivityCheckFilter.Resolver

Method Summary

Modifier and TypeMethod and Description
public long
getTimeoutMillis(E element)

public boolean
removeTimeout(E element)

public void
setTimeoutMillis(E element, long timeoutMillis)

Method Detail

getTimeoutMillisback to summary
public long getTimeoutMillis(E element)
removeTimeoutback to summary
public boolean removeTimeout(E element)
setTimeoutMillisback to summary
public void setTimeoutMillis(E element, long timeoutMillis)
org.glassfish.grizzly.utils back to summary

public Interface DelayedExecutor.Worker<E>

Known Direct Implementers
org.glassfish.grizzly.utils.IdleTimeoutFilter.DefaultWorker, org.glassfish.grizzly.utils.ActivityCheckFilter.DefaultWorker

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true, if the work is done and element has to be removed from the delay queue, or false if the element should be re-registered on the delay queue again
doWork
(E
element to operate upon.
element
)

The method is executed by DelayExecutor once element's timeout expires.

Method Detail

doWorkback to summary
public boolean doWork(E element)

The method is executed by DelayExecutor once element's timeout expires.

Parameters
element:E

element to operate upon.

Returns:boolean

true, if the work is done and element has to be removed from the delay queue, or false if the element should be re-registered on the delay queue again