A thread local special is a special which always has a thread local binding.
This improves the performance of accessing it, because it's not necessary to
check if it already has a global binding. And it has a much more reasonable
semantics, because there's never a question about whether a binding might be
exclusive to a thread or shared between threads.
The semantics I want are slightly different from the ones used by sbcl's
internal define-thread-local currently. (But they are similar to
functionality supported by bordeaux threads.) Defining a thread-local special
should allow you to supply up to _two_ forms: one which is evaluated right
away and gives the initial value on threads that already exist, and one which
is evaluated whenever a thread is created, to give the initial binding for
that newly created thread. The latter is evaluated by the thread doing the
creating, not the newly created thread. Unlike sbcl, which has only one form,
and always evaluates it in the newly created thread.
The conceptual reason for this (which matches my use case) is that there
should be an ordering between the creation of a thread and all subsequent
actions taken by that thread. For CPU reordering, this is trivial--creating a
thread will certainly involve the execution of some serialising
instructions--but for coherency protocols implemented in software, an explicit
handshake may be needed, which may rely on dynamic state in the creating
thread. (It might also be desirable to have a different mechanism for
specifying some actions to be performed by the created thread upon
initialisation--like a thread constructor.)
-E