Create a new process, passing it a function to run.
mp
process-run-function name keywords function &rest arguments => process
name⇩ |
A name for the new process. |
keywords⇩ |
Keywords specifying properties of the new process. |
function⇩ |
A function to apply. |
arguments⇩ |
Arguments to pass to function. |
process⇩ |
The newly created process. |
The function process-run-function
creates a new Lisp process with name name. Other properties of process may be specified in keyword/value pairs in keywords:
:priority |
A fixnum representing the priority for the process. If :priority is not supplied, the process priority becomes the value of the variable *default-process-priority*. |
:mailbox |
A mailbox, a string,
True values specify that process should have a mailbox. A mailbox is used as-is; a string is used as the name of a new mailbox; and Note that both process-send and process-wait-for-event force the relevant process to have a mailbox. |
:internal-server | When true, this indicates that the process is an "internal server", which means that it responds to requests for work from other processes. The main effect of this is that if the only processes that remain are "internal servers", nothing is going to happen, so LispWorks quits. The system marks some of the processes that it creates as "internal server". |
:remote-terminator | A function designator for a function of one argument. |
:local-terminator | A function designator for a function of no arguments. |
:terminate-by-send | A generalized boolean. |
The new process is preset to apply function to arguments and runs in parallel, while process-run-function
returns immediately.
:remote-terminator
, :local-terminator
or :terminate-by-send
define the Terminate Method of the process, which is what process-terminate uses. If more than one of these keyword arguments is supplied, then :remote-terminator
takes precedence over :local-terminator
which takes precedence over :terminate-by-send
.
If remote-terminator is supplied, it must be a function of one argument. When process-terminate is called, it funcalls remote-terminator on the process that process-terminate was called on, which normally will be another process. It should then terminate the process somehow. Typically the process itself will be frequently checking some flag which tells it to exit, and the function remote-terminator just sets this flag. remote-terminator should return non-nil when it is "successful", that is it did something that should cause the process to terminate. process-terminate checks the result of the call to remote-terminator, and if it is nil
it also calls process-kill on the process.
If local-terminator is supplied, it must be a function of no arguments. When process-terminate is called it sends to the process a list with the local-terminator as the only element. That relies on the process itself processing what is sent to it and funcalling the function. This is what general-handle-event does, which is what system processes tend to use. In particular, all processes that are created by CAPI use it.
If terminate-by-send is supplied and non-nil, process-terminate sends the process a list containing current-process-kill (that is it is the same as :local-terminator 'current-process-kill
). CAPI processes use this keyword.
CL-USER 253 > (defvar *stream* *standard-output*) *STREAM* CL-USER 254 > (mp:process-run-function "My process" '(:priority 42) #'(lambda (x) (loop for i below x do (and (print i *stream*) (sleep 1)) finally (print (mp:process-priority mp:*current-process*) *stream*))) 3) #<MP:PROCESS Name "My process" Priority 850000 State "Running"> 0 1 2 42 CL-USER 255 >
current-process-kill
*default-process-priority*
*initial-processes*
list-all-processes
map-processes
process-alive-p
process-join
process-terminate
process-whostate
ps
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:51