Qu

worker_done

Builtin index · Concurrency

result = worker_done(w)

Input: w · Output: result

What it is

Non-blocking check of whether worker w (a Worker handle from spawn) has finished.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = worker_done(w)
w Workernot documented yet
result boolean
Returns a boolean (true/false). The handle stays valid either way — still needs a later join(w) to actually retrieve the result or error.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

heavy(n) := n * n
w = spawn("heavy", 7)                  # runs on its own OS thread

while not worker_done(w)               # non-blocking poll; handle stays valid

end while
result = join(w)                       # blocks for the result (49)

print(result)                          # 49

output
49

from concurrency

How it works

worker_done(w) checks without blocking; the handle stays valid (still needs a later join(w) to get the result).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.