Thread-local state and variables - Factor Documentation (original) (raw)

Threads form a class of objects:
thread

The current thread:

Thread-local variables:

tget ( key -- value )
tset ( value key -- )
tchange ( ..a key quot: ( ..a value -- ..b newvalue ) -- ..b )

Each thread has its own independent set of thread-local variables and newly-spawned threads begin with an empty set.

Global hashtable of all threads, keyed by id:

Threads have an identity independent of continuations. If a continuation is reified in one thread and then reflected in another thread, the code running in that continuation will observe a change in the value output by self.