Interface Session
- All Superinterfaces:
AutoCloseable
The engine creates sessions with ExpressionCompiler.newSession(): one for each language a copy of the rules
uses. It makes a copy when a run needs one and none is idle, and, for an engine built with
copiesAtLoad(n), makes n
copies when the rules load, each session prepared with ExpressionCompiler.warmUp(Session). A run borrows a
copy that no other run is using, so a session is used by one run at a time, though possibly on different threads one
after another, and every condition and action of that language in the run gets the same session. The engine keeps
idle copies for later runs, and closes a session once it no longer needs it: when it drops a copy of the rules, when
load() has replaced the rules and no run is still using them, or when the engine is closed.
A language whose compiled expressions are safe to run on several threads at once, and that keeps no other state
between runs, returns none().
Implemented by expression languages. A method added to this interface is a default method, so an
existing language keeps compiling and working.
- See Also:
-
Method Summary
-
Method Details
-
none
Returns the session of a language that keeps no state between runs. Closing it does nothing.- Returns:
- The shared empty session
-
close
default void close()Releases what the session holds. The engine calls it once, when no run is using the session, on whichever thread finishes with it: the run's thread, or the thread that callsload()orclose()when the session is idle. A language whose runtime is bound to a thread must not assume which. By default, does nothing. Anything it throws is logged at WARN, unless arun()orload()it started logged it already, and the engine still closes the other sessions and compilers it is closing. Only a fatalErrorthen fails the run,load()orclose(): it's rethrown unchanged, unless a fatal error of the call's own came first. AnInterruptedExceptionin the cause chain of what it throws, or suppressed there, puts back the interrupt status of the thread that closes it, which can be a run's thread, so a run on that thread, such as the outer run of a nested one, then stops as interrupted.- Specified by:
closein interfaceAutoCloseable
-