Statically typed processes
This module provides a slightly higher-level view on processes, but is also a bit more restricted than the primitives in [root:Netmcore].
Please read [root:Netmcore_basics] for an introduction into using this module. There is also [root:Netmcore_tut] with more advanced techniques.
A fork point can start a new process with argument
A join point can wait until a process finishes with a result
let (fp,jp) = def_process proc: Defines a process (which must happen
in the master process), so that:
let pid = start fp arg: Starts the new process and passes the argument
argto it. The process runs
proc argwhich will finally result in a value
let r_opt = join jp pid: Waits until the process identified by
pidfinishes, and returns the result as
r_opt = Some r. On error, it returns
def_process should be called at module initialization time
before any process is started. This interface is not designed for
let pid = start fp arg: Starts a new process at the fork point
fp with argument
arg. This means that the process is forked
from the master process, and that the value of
arg is sent to it
Marshal. The returned process ID is Netmulticore's own
ID and not to be confused with the ID assigned by the operating
inherit_resources: Certain resources are only accessible by
the process when they are inherited to it. This is the case for
`Posix_shm_preallocated. This can be set to
`All to inherit
all inheritable resources, or to
`Resources l to only inherit
the resources of
l. By default, no resources are inherited.
let r_opt = join jp pid: Waits until the process
and uses the join point
jp to extract the result. The result
is returned as
Some r on success, and
None on error.
Result values are transmitted from the joining process to
this function using
Marshal. Errors include uncaught exceptions
as well as unexpected process termination (
If the process referenced by
pid is not an instance that belongs
jp, the function will fail.
This function must not be called from the master process (which is not allowed to block until a result is available).
join, but it is not waited for the termination of the process.
If the process is not yet done, this function returns
It also returns
None if the process terminated with an error or did
not set a result value for other reasons.
join, this function can be called in the master process.
Releases a fork point so it is deleted from the internal resource table.