A string or symbol
argument is a string or symbol that names the process. The
argument is a function to be run in the process, and the
argument is a wait function that determines when the process function is run. The value of
is a list of arguments to which the process function is applied. The value of
is a list of arguments to which the wait function is applied. The :
argument is a fixnum that specifies a priority for the process. The default priority is the value of
, and is usually 0.
When the wait function, applied to the
, returns a value other than
, the process function is applied to the function-arguments. The process function is executed inside an
form. If an error occurs in a simple process, that process is stopped and a continuable error is signaled in the process that was running at the time the simple process was started (or the last process to run if the system was idle). Continuing from the error restarts the simple process.
Because a simple process has no stack of its own, it can be executed on an arbitrary stack. However, simple processes have restrictions, the primary one being that they cannot block. The following interfaces cannot be used in a simple process:
mp:mailbox-read(with an empty mailbox)
Other Common Lisp functions might not work if they attempt to block. This applies in particular to I/O functions on streams such as pipes and to
on a hash table that another process is mapping over.
For more information, see Multiprocessing.
The following example creates a simple process that prints the value of
to the background output when the value is other than
. The process function then sets *a* to
. From a listener, the value of *a* can be set to trigger the process to run once and then sleep again.
(defvar *a* 'i)
(defun b () *a*)
(setq r (mp:create-simple-process 'test-proc 'a 'b))
#<MP::SIMPLE-PROCESS Name TEST-PROC Priority 0 State NIL>