public class ProgressEventDispatcher
extends java.lang.Object
implements java.io.Closeable
ProgressEvent
s associated with a managed Allocation
. Keeps track of
the allocation units that are remaining so that it can emit the remaining progress units upon
close()
.
This class is not thread-safe. Only use a single instance per thread and create child
instances with newChildProducer()
.
Modifier and Type | Class and Description |
---|---|
static interface |
ProgressEventDispatcher.Factory
Creates a new
ProgressEventDispatcher based off an existing ProgressEventDispatcher . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Emits the remaining allocation units as progress units in a
ProgressEvent . |
void |
dispatchProgress(long progressUnits)
|
ProgressEventDispatcher.Factory |
newChildProducer()
Creates a new
ProgressEventDispatcher.Factory for a ProgressEventDispatcher that manages a child Allocation . |
static ProgressEventDispatcher |
newRoot(EventHandlers eventHandlers,
java.lang.String description,
long allocationUnits)
Creates a new
ProgressEventDispatcher with a root Allocation . |
public static ProgressEventDispatcher newRoot(EventHandlers eventHandlers, java.lang.String description, long allocationUnits)
ProgressEventDispatcher
with a root Allocation
.eventHandlers
- the EventHandlers
description
- user-facing description of what the allocation representsallocationUnits
- number of allocation unitsProgressEventDispatcher
public ProgressEventDispatcher.Factory newChildProducer()
ProgressEventDispatcher.Factory
for a ProgressEventDispatcher
that manages a child Allocation
. Since each child Allocation
accounts for 1 allocation unit of its parent,
this method decrements the remainingAllocationUnits
by 1
.ProgressEventDispatcher.Factory
public void close()
ProgressEvent
.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public void dispatchProgress(long progressUnits)
progressUnits
- units of progress