Factor handbook » The language » Co-operative threads » Thread-local state and variables

Next:self ( -- thread )


Class description
A thread. The slots are as follows:
ida unique identifier assigned to each thread.
exit-handlera quotation run when the thread is being stopped.
namethe name passed to spawn.
quotthe initial quotation passed to spawn.
runnablewhether the thread is runnable. Initially it is, f.
statea string indicating what the thread is waiting for, or f. This slot is intended to be used for debugging purposes.
contexta box holding an alien pointer to the threads context object.

Variable value
Current value in global namespace:


TUPLE: thread
{ name string initial: "" } { quot callable initial: [ ] }
{ exit-handler callable initial: [ ] }
{ id integer initial: 0 } { context box initial: T{ box } }
state runnable mailbox
{ variables hashtable initial: H{ } } sleep-entry ;