JBoss Common Classes 2.2.17.GA

org.jboss.util.timeout
Class TimeoutFactory

java.lang.Object
  extended by org.jboss.util.timeout.TimeoutFactory

public class TimeoutFactory
extends Object

The timeout factory.

Version:
$Revision: 2787 $
Author:
Ole Husgaard, Dimitris Andreadis, Elias Ross, Adrian Brock

Constructor Summary
TimeoutFactory()
          Constructs a new TimeoutFactory that uses the default thread pool
TimeoutFactory(ThreadPool threadPool)
          Constructs a new TimeoutFactory that uses the provided ThreadPool
 
Method Summary
 void cancel()
          Cancels all submitted tasks, stops the worker thread and clean-ups everything except for the thread pool.
static Timeout createTimeout(long time, TimeoutTarget target)
          Schedules a new timeout using the singleton TimeoutFactory
static TimeoutFactory getSingleton()
           
 boolean isCancelled()
           
 Timeout schedule(long time, Runnable run)
          Schedules a new timeout.
 Timeout schedule(long time, TimeoutTarget target)
          Schedules a new timeout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeoutFactory

public TimeoutFactory(ThreadPool threadPool)
Constructs a new TimeoutFactory that uses the provided ThreadPool

Parameters:
threadPool -

TimeoutFactory

public TimeoutFactory()
Constructs a new TimeoutFactory that uses the default thread pool

Method Detail

getSingleton

public static TimeoutFactory getSingleton()

createTimeout

public static Timeout createTimeout(long time,
                                    TimeoutTarget target)
Schedules a new timeout using the singleton TimeoutFactory

Parameters:
time -
target -
Returns:
the timeout

schedule

public Timeout schedule(long time,
                        TimeoutTarget target)
Schedules a new timeout.

Parameters:
time - absolute time
target - target to fire
Returns:
the timeout

schedule

public Timeout schedule(long time,
                        Runnable run)
Schedules a new timeout.

Parameters:
time - absolute time
run - runnable to run
Returns:
the timeout

cancel

public void cancel()
Cancels all submitted tasks, stops the worker thread and clean-ups everything except for the thread pool. Scheduling new timeouts after cancel is called results in a IllegalStateException.


isCancelled

public boolean isCancelled()
Returns:
true if the TimeoutFactory has been cancelled, false if it is operational (i.e. accepts timeout schedules).

JBoss Common Classes 2.2.17.GA

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.