(rontolisp) docs
← Functions

rontolisp:make-mutex

(rontolisp:make-mutex)

Returns a fresh mutual-exclusion lock, as an opaque handle. Pass it to rontolisp:with-mutex (or to rontolisp:mutex-acquire / rontolisp:mutex-release) and to nothing else: what the handle actually is differs per backend, so printing one, comparing two with <, or doing arithmetic on it is not portable. Comparing a handle with eq/eql to itself does work.

rontolisp really runs concurrent code — rontolisp:http-handler puts one virtual thread per request on the interpreter and the JVM backend, and rontolisp:make-thread lets your own code spawn one — which is what a lock is for. On both WASM backends there is only ever one thread, so the primitives are no-ops there; the same source runs everywhere.

The lock is reentrant: the thread holding it may acquire it again, and must release it as many times as it acquired it.

Limitations

  • The handle is opaque and backend-dependent — do not print or order it.
  • Macros and these primitives have no function value: #'rontolisp:make-mutex is an error.