Multi-Process library
Concurrent | Multi-Process library |
(mosh concurrent) | Multi-Process Library. |
Functions | |
spawn | Create a process which executes proc. |
spawn-link | spawn and link. |
process-exit | exit process with status. |
! | Send a message object to pid process. |
link | Link self and other process. |
unlink | unlink linked process |
self | Returns self pid. |
receive | Receive a message which matches <match clause>. |
join! | Waits termination of process. |
register | Register a process by name. |
whereis | Look up process by name |
make-process-error | Make a process-error |
process-error? | Returns #t if obj is process-error condition, otherwise #f. |
process-error | Returns error state of process-error condition. |
sleep | sleep n msec. |
Multi-Process Library.
N.B. If you share R6RS records between multiple processs, define them as nongenerative.
Functions | |
spawn | Create a process which executes proc. |
spawn-link | spawn and link. |
process-exit | exit process with status. |
! | Send a message object to pid process. |
link | Link self and other process. |
unlink | unlink linked process |
self | Returns self pid. |
receive | Receive a message which matches <match clause>. |
join! | Waits termination of process. |
register | Register a process by name. |
whereis | Look up process by name |
make-process-error | Make a process-error |
process-error? | Returns #t if obj is process-error condition, otherwise #f. |
process-error | Returns error state of process-error condition. |
sleep | sleep n msec. |
Create a process which executes proc. On Mosh, a process means an independent VM instance. The process which is spawn-ed and calls spawn share nothing. Each processes has own independent namespace.
(spawn proc-expr arg import-spec)
proc-expr | (lambda (arg) ...) expression to execute. |
arg | argument for proc-expr. |
import-spec | import spec. |
(spawn (lambda (x) (display x)) 'hello '((rnrs)))
pid
Receive a message which matches <match clause>. If there is no message or no matched message, receive is blocked. <match clause> may have [after timeout ...], receive wait timeout msec and returns
(receive <match clause> ...)
;; wait and receive ('exit why) message. (receive [('exit why) (display why)]) ;; wait two pattern messages. (receive [('exit why) (display why)] [x (display "unknown message") (display x)]) ;; wait with timeout (receive [('exit why) (display why)] [after 1000 (display "exit why doesn't come in 1000 msec")])