|
JADE v6.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.dautelle.realtime.Context
com.dautelle.realtime.LocalContext
This class represents a local context; it is used to define locally scoped environment settings.
These settings are inherited by
concurrent executions when performed
within the scope of the local context. For example:
LocalContext.enter(); // Enters local context scope.
try {
MY_VAR.setValue(myValue);
ConcurrentContext.enter();
try {
// Concurrent executions inherit local setting of MY_VAR
ConcurrentContext.execute(...);
ConcurrentContext.execute(...);
} finally {
ConcurrentContext.exit();
}
} finally {
LocalContext.exit(); // End of local context scope.
}
static final LocalContext.Variable MY_VAR = new LocalContext.Variable();
Settings outside of a LocalContext scope, affects all threads
(global default value). For example:
public static final LocalContext.Variable DEBUG = new LocalContext.Variable();
public static void main(String[] args) {
DEBUG.setValue(new Boolean(true)); // Affects all threads.
...
}
Locally scoped settings are typically wrapped by a static method. For example:
LargeInteger.setModulus(m); // Performs integer operations modulo m.
Length.showAs(NonSI.INCH); // Shows length in inches.
RelativisticModel.select(); // Uses relativistic physical model.
QuantityFormat.setInstance(format); // Changes current format.
| Nested Class Summary | |
static class |
LocalContext.Variable
This class represents a LocalContext variable. |
| Method Summary | |
static void |
enter()
Enters a LocalContext. |
static void |
exit()
Exits the current LocalContext. |
| Methods inherited from class com.dautelle.realtime.Context |
current, getInner, getOuter, getOwner, pop, push, push |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static void enter()
LocalContext.
public static void exit()
LocalContext.
java.lang.ClassCastException - if the current context is not a
LocalContext.
|
JADE v6.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||