5.2 Issues in multitasking
throwto allow a transfer of control in which the destination is determined by the dynamic environment. In addition, the special form
unwind-protectensures that certain cleanup code is always executed, even if there is a
throwfrom within the protected form of the
unwind-protectto a tag outside of the
In the Multitasking Facility, each process maintains its own stack of
catch tags and
unwind-protect forms. When a process uses the special form
throw to perform a nonlocal control transfer, its stack is searched to find the appropriate tag and its u
nwind-protect cleanup forms are executed; stacks from other processes are not searched.
If your program is running in one process and you need to have another process exit its computation, you can use the function
interrupt-process to cause the other process to perform a throw, as the following example demonstrates:
(interrupt-process *some-process* #'(lambda () (throw 'tag value)))If
process-waitor a related function has suspended
*some-process*, this code causes the process to wake up and throw to the appropriate tag. This method is the only way that a process can return from a call to the function
When you use the function
kill-process to kill a process, all the
unwind-protect cleanup forms that are pending on that process's stack are performed before the process is killed. If a cleanup form contains a
go, or a
return to a location outside of the cleanup form, the unwinding of the stack is aborted.
You can use the optional argument
kill-process to kill the process immediately without attempting to execute cleanup forms or to unwind the stack. However, this method of killing a process is dangerous and should only be used as a last resort when a more reasonable method will not work. Files in the process are not closed, locks are not released, and all other details of process cleanup are lost.
Generated with Harlequin WebMaker