Class Controller

The controller object cannot be manually created. It is automatically created when an interpreter is obtained from a knowledge base, and it is shared when an interpreter is forked from an interpreter. The controller carries the basic input/output streams and thread local predicates of an interpreter. For an instrumented interpreter it might also carry spy points and break points.

Interactors running in a primary thread might be controlled by a secondary thread. A signal can be issued from a controlling thread by calling setSignal(m) where m is non-null. A signal is an error term wrapped into a class InterpreterMessage instance. It can be consumed by calling throw setSignal(null) after catching InterruptedException. It should be also consumed after catching InterruptedIOException but not after SocketTimeoutException.

The controlled thread will only be interrupted when the conjunctive condition of a signal and a interrupt mask is satisfied. The current signal can be retrieved by the method getSignal(). The interrupt mask can be retrieved by the method getMask(). The interrupt mask can be changed by the method setMask(). Both methods setSignal() and setMask() set and clear the interrupted bit depending on whether the conjunctive condition is satisfied or not.

The methods setInuse() and getInuse() can be used to set and retrieve the interpreter object a controller is currently in use. Further the methods setFence() and currentController() can be used to set and retrieve the thread a controller occupies. Both information pieces are au-tomatically tracked by the call-in interactor, so that the application programmer usually doesn’t have to bother with these methods.

package jekpro.tools.call;

public final class Controller {
public final InterpreterMessage getSignal();
public final InterpreterMessage setSignal(InterpreterMessage m);
public final boolean getMask();
public final boolean setMask(boolean m);

public final Interpreter getInuse();
public final Interpreter setInuse(Interpreter e);

public static Controller currentController(Thread t);
public final Thread setFence(Thread t);
}

Comments