Section "signal"

Situations might demand that a secondary thread controls a primary thread. The programming interface allows raising a soft signal in a primary Prolog thread from a secondary thread. The effect on the primary Prolog thread will be that the signal message is thrown as an error the first possible moment a call port is reached.

error(system_error(_),_)

The secondary thread is free to signal whatever message it likes. Among the errors the Prolog system recognizes urgent errors as above. Urgent errors are automatically passed down in a catch/3. An example of such an urgent error is the error issued by the predicate abort/1. Urgent errors can still be catched by the predicate sys_trap/3.

The error terms are displayed using the multilingual strings facility. Whereby strings acting as formatting templates are used when the error term has further parameters. Multilingual strings can be retrieved by the predicates get_string/[2,3]. Multilingual strings can be defined by ex-tending the predicate string/3. Locales are assumed underscore separated.

The following signal predicates are provided:

must(A):
The predicate succeeds once if A succeeds. Otherwise, the predicate throws an error.
chain(A, B):
The predicate succeeds whenever A and B succeed. If A throws an exception, then B is called once and an exception is chained.
abort:
The predicate throws a system error of type user abort.
once_cleanup(G, C):
setup_once_cleanup(S, G, C):
The predicate succeeds once if G succeeds.The predicate succeeds once if G succeeds. The clean-up C is called when G fails, succeeds or throws an exception. The ternary predicate permits an initial shielded call of a setup S.
shield(G):
The predicate succeeds whenever the goal G succeeds. The goal is executed without auto-yield.
unshield(G):
The predicate succeeds whenever the goal G succeeds. The goal is executed with auto-yield.
get_string(K, V):
get_string(K, L, V):
The predicate succeeds in V with the value for the key K. The ternary predicate allows overriding the current locale by L.
strings(K, L, V):
The predicate succeeds in the key K, the value V and the locale L. The predicate can be extended by libraries and applications..

Kommentare