Skip to content

Concurrency

Given a file named “pen.json” with:

{
"type": "application",
"dependencies": {
"Os": "pen:///os"
}
}

Given a file named “main.pen” with:

main = \(ctx context) none {
f = go(\() none { none })
f()
}

When I successfully run pen build

Then I successfully run ./app.

Given a file named “main.pen” with:

import Os'Process
main = \(ctx context) none {
xs = race([[none] [none none]])
if [x, ...xs] = xs {
x()
} else {
Process'Exit(ctx.Os, 1)
}
}

When I successfully run pen build

Then I successfully run ./app.

Given a file named “main.pen” with:

import Os'Process
main = \(ctx context) none {
xs = race([[none] [none none], [none none]])
if [x, ...xs] = xs {
x()
} else {
Process'Exit(ctx.Os, 1)
}
}

When I successfully run pen build

Then I successfully run ./app.

Given a file named “main.pen” with:

import Os'Context { Context }
import Os'Process
import Os'Time
main = \(ctx context) none {
xs = race([[boolean]
[boolean (\() boolean { loop(ctx.Os) false })()],
[boolean true],
])
if [x, ...xs] = xs {
if x() {
none
} else {
Process'Exit(ctx.Os, 1)
}
} else {
Process'Exit(ctx.Os, 1)
}
}
loop = \(ctx Context) none {
Time'Sleep(ctx, 1)
loop(ctx)
}

When I successfully run pen build

Then I successfully run ./app.

Given a file named “main.pen” with:

import Os'Process
main = \(ctx context) none {
xs = race([[none] [none none], [none none]])
if xs == [none none, none] {
none
} else {
Process'Exit(ctx.Os, 1)
}
}

When I successfully run pen build

Then I successfully run ./app.