Qu

semaphore_release

Builtin index · Concurrency

semaphore_release(s)

Input: s · Output: no output

What it is

Returns one permit to semaphore handle s (incrementing the available count by one).

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
semaphore_release(s)
s —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.

s = semaphore(2)                       # 2 permits available

print(semaphore_available(s))          # 2

semaphore_acquire(s)                   # take one

print(semaphore_available(s))          # 1

semaphore_release(s)                   # give it back

print(semaphore_available(s))          # 2

output
2
1
2

from concurrency

How it works

semaphore_release(s) — returns a permit. Releasing more times than acquired just grows the available count past its starting size (the same "unbalanced release" footgun any semaphore has, in any language) — not checked, since a legitimate pattern (a semaphore used purely as a signal, with more releases than acquires) does exist.

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