public class CopyForAnotherThread extends CopyContext
IThreadAware
objects for use in another thread.
The following example shows how to use this class to create a copy of an object that can be used simultaneously with the original from another thread:
// An object that we need to copy for another thread. In this case, we are
// copying an evaluator.
AxesEvaluator axesEvaluator = GeometryTransformer.getAxesTransformation(fromAxes, toAxes);
// Call the static copy method.
AxesEvaluator copiedEvaluator = CopyForAnotherThread.copy(axesEvaluator);
Constructor and Description |
---|
CopyForAnotherThread() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
copy(T oldObject)
Copies an object for use in another thread.
|
<T> T |
updateReference(T oldObject)
Updates a given reference, returning a reference to use in its place.
|
addObjectMapping, clearObjectMapping, clone, cloneIfNotMapped, getObjectMapping
public static <T> T copy(T oldObject)
The following example shows how to use this method to create a copy of an object that can be used simultaneously with the original from another thread:
// An object that we need to copy for another thread. In this case, we are
// copying an evaluator.
AxesEvaluator axesEvaluator = GeometryTransformer.getAxesTransformation(fromAxes, toAxes);
// Call the static copy method.
AxesEvaluator copiedEvaluator = CopyForAnotherThread.copy(axesEvaluator);
T
- The type of the object to copy.oldObject
- The object to copy.oldObject
that can be used simultaneously with oldObject
from
two different threads.public <T> T updateReference(T oldObject)
In addition to the base class behavior of updating mappings (see
CopyContext#updateReference(T)
for more information), this method clones any objects that
implement IThreadAware
and report false for IsThreadSafe
(get
).
updateReference
in class CopyContext
T
- The type of the object reference.oldObject
- The old reference to update.