Title:

onExit() - set or add an expression block to be evaluated when the thread exits, either normally (exit()) or abnormally (e.g.cancel())

Perhaps this should be on.exit and evaluated differently in the context of a thread rather than a function!

Usage:

onExit(expression,append=F)

Arguments:

expression:
an expression (or group of expressions) to be evaluated when the thread terminates. The expressions are evaluated in the name space of the thread in the same manner as task expressions are evaluated in that thread.
append:
if this is T, the expression is added to the list of existing expressions to be evaluated on exit of this thread. If F, the existing expressions are removed from this thread and replaced by expression

Side Effect:

the list of expressions to be evaluated in this thread when this thread terminates is modified.

NOTE:

This, like return, should be evaluated differently in the context of a function and a toplevel expression in a thread. It seems like this should be relatively trivial and I think it is.

See Also:

exit()
thread()
on.exit()

Examples:

    tA = thread(Quote({fit <- "No output"; onExit(Quote(print(fit,"output"))); fit = lm(x,y))})

Key Words:

User Level Threads

Last modified: Thu Feb 6 15:12:40 1997