01: /*
02: * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
03: * Copyright (C) 2007 - Javolution (http://javolution.org/)
04: * All rights reserved.
05: *
06: * Permission to use, copy, modify, and distribute this software is
07: * freely granted, provided that this notice is preserved.
08: */
09: package javolution.lang;
10:
11: import javolution.text.Text;
12:
13: /**
14: * <p> This interface identifies <a href="http://www.rtsj.org/">RTSJ</a> safe
15: * classes with predictable response time and supporting custom {@link
16: * javolution.context.AllocatorContext allocation} policies (e.g.
17: * {@link javolution.context.StackContext "stack"} allocations).</p>
18: *
19: * <p> Instances of this class are typically created through an
20: * {@link javolution.context.ObjectFactory ObjectFactory}. For example:
21: * [code]
22: * public final class Complex implements Realtime, ValueType {
23: * private double _real;
24: * private double _imaginary;
25: * private static ObjectFactory<Complex> FACTORY = new ObjectFactory() {
26: * protected Complex create() { return new Complex(); }
27: * }
28: * private Complex() { }
29: * public static Complex valueOf(double real, double imaginary) {
30: * Complex c = FACTORY.object();
31: * c._real = real;
32: * c._imaginary = imaginary;
33: * return c;
34: * }
35: * public Complex copy() {
36: * return Complex.valueOf(_real, _imaginary);
37: * }
38: * public Text toText() {
39: * return Text.valueOf(_real).plus(" + ")
40: * .plus(Text.valueOf(_imaginary).plus("i"));
41: * }
42: * }[/code]<p>
43: *
44: * <p> It should be noted that classes with no static reference field
45: * or with only static final {@link Immutable immutable} fields are
46: * always RTSJ safe. Such classes may implement this interface
47: * and be used while running in scoped memory (RTSJ) or non-heap
48: * {@link javolution.context.AllocatorContext allocators} (Javolution).</p>
49: *
50: * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
51: * @version 5.0, May 6, 2007
52: */
53: public interface Realtime {
54:
55: /**
56: * Returns the textual representation of this real-time object
57: * (equivalent to <code>toString</code> except that the returned value
58: * can be {@link javolution.context.StackContext "stack"} allocated and
59: * supports fast concatenation).
60: *
61: * @return this object's textual representation.
62: */
63: Text toText();
64: }
|