wanted: DEFINE-THREAD-LOCAL-VARIABLE
Bug #310204 reported by
Nikodemus Siivola
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Incomplete
|
Wishlist
|
Gábor Melis |
Bug Description
A way to initialize thread local variables.
Discussed a number of times on sbcl-devel.
Collect links to those discussions /here/.
This thread on sbcl-devel starts with a proposed patch and ends with another:
http://
Dealing with already running threads is not implemented.
Changed in sbcl: | |
status: | New → Incomplete |
importance: | Undecided → Wishlist |
description: | updated |
Changed in sbcl: | |
assignee: | nobody → melisgl |
To post a comment you must log in.
Another way would be to introduce a special form THREAD-LOCAL-VALUE that is
inspired by LOAD-TIME-VALUE.
(THREAD- LOCAL-VALUE expr) reserves space in thread-local memory, initialized
by the result of evaluating EXPR at load-time (or at execution time, but
guaranteed to be evaluated only once.)
This way DEFINE- THREAD- LOCAL-VARIABLE could be implemented as
(DEFGLOBAL FOO (THREAD-LOCAL-VALUE expr))
or similiarly. The advantage is that this would also allow C-style static variables:
(defun quux (x)
(let ((count (thread-local-value 0)))
(incf count)
(list :x :count count)))