This interface identifies RTSJ safe
classes with predictable response time and supporting custom
javolution.context.AllocatorContext allocation policies (e.g.
javolution.context.StackContext "stack" allocations).
Instances of this class are typically created through an
javolution.context.ObjectFactory ObjectFactory . For example:
[code]
public final class Complex implements Realtime, ValueType {
private double _real;
private double _imaginary;
private static ObjectFactory FACTORY = new ObjectFactory() {
protected Complex create() { return new Complex(); }
}
private Complex() { }
public static Complex valueOf(double real, double imaginary) {
Complex c = FACTORY.object();
c._real = real;
c._imaginary = imaginary;
return c;
}
public Complex copy() {
return Complex.valueOf(_real, _imaginary);
}
public Text toText() {
return Text.valueOf(_real).plus(" + ")
.plus(Text.valueOf(_imaginary).plus("i"));
}
}[/code]
It should be noted that classes with no static reference field
or with only static final
Immutable immutable fields are
always RTSJ safe. Such classes may implement this interface
and be used while running in scoped memory (RTSJ) or non-heap
javolution.context.AllocatorContext allocators (Javolution).
author: Jean-Marie Dautelle version: 5.0, May 6, 2007 |