|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.microsoft.tfs.util.tasks.TaskMonitorService
public class TaskMonitorService
TaskMonitorService
is a service that is used to manage
TaskMonitor
instances. Upper layer code uses
TaskMonitorService
to make TaskMonitor
s available to lower
layer code. Lower layer code that implements a long-running task uses
TaskMonitorService
to obtain a TaskMonitor
instance to use
for the task.
TaskMonitorService
exists for two reasons. First, it ensures that
TaskMonitor
s can be passed across layers without having to explicitly
pass them by method arguments from layer to layer. This is accomplished
through the use of thread local storage. The upper layer that makes a task
monitor available must run on the same thread as the lower layer that
retrieves the TaskMonitor
.
The second reason the TaskMonitorService
exists is to decouple the
layer that produces a TaskMonitor
from the layer that consumes it.
Either layer may be made TaskMonitor
-aware without the other layer
being TaskMonitor
aware. If the upper layer produces a
TaskMonitor
and nothing consumes it, no progress monitoring or
cancelation will occur but everything will still work. If the lower layer
asks for a TaskMonitor
and one has not been set, a dummy
implementation is returned.
Within each thread, the TaskMonitorService
is stack based. Each
TaskMonitor
producer calls pushTaskMonitor(TaskMonitor)
to
add a TaskMonitor
to the service. This call must be matched by
a call to popTaskMonitor()
, which should occur in the same layer
that pushed it. The stack-based implementation is intended mostly to support
sub-tasking in which sub-TaskMonitor
s are pushed on top of their
parents.
TaskMonitor
Method Summary | |
---|---|
static TaskMonitor |
getTaskMonitor()
Called to retrieve a TaskMonitor from this
TaskMonitorService . |
static TaskMonitor |
popTaskMonitor()
Called to pop a TaskMonitor from this thread's
TaskMonitor stack. |
static TaskMonitor |
popTaskMonitor(boolean callDone)
Called to pop a TaskMonitor from this thread's
TaskMonitor stack. |
static void |
pushTaskMonitor(TaskMonitor taskMonitor)
Called to push a TaskMonitor onto this thread's
TaskMonitor stack. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static TaskMonitor getTaskMonitor()
TaskMonitor
from this
TaskMonitorService
. This method will always return a usable
TaskMonitor
, even if one has not been set into the service.
TaskMonitor
to use (never null
)public static void pushTaskMonitor(TaskMonitor taskMonitor)
TaskMonitor
onto this thread's
TaskMonitor
stack. This call must be matched by a call to
popTaskMonitor()
. This requirement implies the use of
try
/finally
to satisfy it.
taskMonitor
- a TaskMonitor
to push (must not be null
)public static TaskMonitor popTaskMonitor()
Called to pop a TaskMonitor
from this thread's
TaskMonitor
stack. This call must be matched with a
previous call to pushTaskMonitor(TaskMonitor)
. This requirement
implies the use of try
/finally
to satisfy it.
Before this method returns, TaskMonitor.done()
is called on the
popped TaskMonitor
. This is almost always safe and the right
thing to do (done()
can be safely called multiple times). In
the rare case that this is not desired, call
popTaskMonitor(boolean)
instead.
TaskMonitor
that was popped off the stackpublic static TaskMonitor popTaskMonitor(boolean callDone)
TaskMonitor
from this thread's
TaskMonitor
stack. This call must be matched with a
previous call to pushTaskMonitor(TaskMonitor)
. This requirement
implies the use of try
/finally
to satisfy it.
callDone
- if true
, TaskMonitor.done()
will be called on
the popped TaskMonitor
before it is returned
TaskMonitor
that was popped off the stack
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |