|
J avolution v3.7 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavolution.realtime.Context
javolution.realtime.PoolContext
public class PoolContext
This class represents a pool context; it is used to recycle objects transparently, reduce memory allocation and avoid garbage collection.
Threads executing in a pool context may allocate objects from
the context's pools (also called "stack") through an
ObjectFactory. Allocated objects are recycled automatically
upon exit. This recycling is almost
instantaneous and has no impact on performance.
Objects allocated within a pool context should not be directly
referenced outside of the context unless they are
exported (e.g. result being returned)
or preserved (e.g. shared static
instance). If this simple rule is followed, then pool context are
completely safe. In fact, pool contexts promote the use of immutable
objects (as their allocation cost is then negligible with no adverse
effect on garbarge collection) and often lead to safer, faster and
more robust applications.
Finally, the framework guarantees that all pool objects belongs to
the same memory area (the memory area where the pool context resides).
In other words, pool contexts allocated in ImmortalMemory can safely
be used by NoHeapRealtimeThread executing in
ScopedMemory.
| Field Summary | |
|---|---|
protected static XmlFormat |
XML
Holds the XML representation for pool contexts. |
| Constructor Summary | |
|---|---|
PoolContext()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
clear()
Moves all objects belonging to this pool context to the heap. |
static PoolContext |
current()
Returns the current pool context or null |
static void |
enter()
Enters a PoolContext allocated in the same memory area
as the memory area of the current context. |
protected void |
enterAction()
The action to be performed after this context becomes the current context. |
static void |
exit()
Exits the current PoolContext. |
protected void |
exitAction()
The action to be performed before this context is no more the current context. |
| Methods inherited from class javolution.realtime.Context |
|---|
enter, enter, exit, exit, getOuter, getOwner |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final XmlFormat XML
| Constructor Detail |
|---|
public PoolContext()
| Method Detail |
|---|
public static PoolContext current()
null if the current
thread does not execute within a pool context.
- Returns:
- the current pool context.
public static void enter()
PoolContext allocated in the same memory area
as the memory area of the current context.
public static void exit()
PoolContext.
java.lang.IllegalStateException - if the current context
is not an instance of PoolContext.public void clear()
clear in class Contextprotected void enterAction()
Context
enterAction in class Contextprotected void exitAction()
Context
exitAction in class Context
|
J avolution v3.7 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||