Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 1.15 KB

rontolisp-current-thread.md

File metadata and controls

29 lines (23 loc) · 1.15 KB

rontolisp:current-thread

(rontolisp:current-thread)

Returns the calling thread's own opaque thread handle. It works for any thread — the main thread and served requests included, not only rontolisp:make-thread spawns — and it is eq-stable: repeated calls from one thread return the same handle, so it can key an eq hash table. That property is what the bt2:current-thread shim (and through it dbi's per-thread connection cache) relies on. Inside a thread rontolisp:make-thread spawned, it is the handle make-thread returned.

(let ((h (rontolisp:current-thread)))
  (list (rontolisp:threadp h)
        (eq h (rontolisp:current-thread))
        (rontolisp:thread-alive-p h))) ; => (T T T)

Threads are real on the interpreter and the JVM backend. Both WASM backends are single-threaded by construction and do not compile this function; the bordeaux-threads/bt2 shim's current-thread signals a clear error there at call time.

Limitations