OEP

0161

Title

Named FORKING blocks

Summary

Make the FORKING context visible to programmers.

Owner

Adam Sampson <ats@offog.org>

Status

Proposed

Date-Proposed

2007-09-27

Keywords

language fork

The existing FORKING mechanism (see OEP/115) has a couple of drawbacks:

I propose that FORKING blocks should be named, and FORK should take the name of the block to fork in:

FORKING fa
  SEQ
    ...
    FORKING fb
      SEQ
        FORK fa, long.lived.proc (args)
        FORK fb, short.lived.proc (args)

These named blocks would be called forking contexts, and could be passed as PROC arguments. PROCs that spawned processes and didn't wait for them to exit would then have to take a context:

PROC start.server (RESULT SOME.CT! cli, FORKING ctx)
  SOME.CT? svr:
  SEQ
    cli, svr := MOBILE SOME.CT
    FORK ctx, server (svr)
:
FORKING fa
  SEQ
    start.server (cli, fa)
    ...

It is sometimes useful to spawn a process and simply not care when it exits -- i.e. not require it to have a forking context at all. For this purpose, we could reuse the existing FORK syntax:

FORK some.process (args)

Provided that we didn't also maintain the existing FORKING syntax, this would not silently change the behaviour of existing programs.

OEP/161 (last edited 2007-09-27 11:45:36 by ats1)