Qu

mutex_set

Builtin index · Concurrency

mutex_set(m, v)

Input: m, v · Output: no output

What it is

Overwrites the value stored in mutex handle m with v (any value, any type), discarding the old one unconditionally — no read of the previous value is involved.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
mutex_set(m, v)
m —not documented yet
v —not documented yet
no output—

Examples

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

running_max(current) := max(current, 7)

m = mutex(0)
mutex_set(m, 3)                        # overwrite -- no read involved

mutex_update(m, "running_max")         # atomic read-modify-write via a user fn

print(mutex_get(m))                    # 7

output
7

from concurrency

How it works

mutex_set(m, v) — overwrite the current value.

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