public interface Realtime
This interface identifies RTSJ safe
classes with predictable response time and supporting custom allocation
policies (e.g.
"stack"
allocations).
Instances of this class are typically created through an
ObjectFactory
. For example:
public final class Complex implements Realtime, ValueType {
private double _real;
private double _imaginary;
private static ObjectFactory<Complex> 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"));
}
}
It should be noted that classes with no static reference field
or with only static final immutable
fields are
always RTSJ safe. Such classes may implement this interface
and be used while running in scoped memory (RTSJ) or non-heap
allocators
(Javolution).
Modifier and Type | Method and Description |
---|---|
Text |
toText()
Returns the textual representation of this real-time object
(equivalent to
toString except that the returned value
can be "stack" allocated and
supports fast concatenation). |
Copyright © 2005 - 2007 Javolution.