thread
thread::create ?-joinable? ?-preserved? ?-isolation LEVEL? ?-caps LIST? ?-compute UNITS? ?-meter NAME? ?script?
The thread package: a thread is one interpreter that runs a script, with its own limits. Threads talk with messages: thread::send runs a script in another thread. Each thread of a group gets the limits of the host, and the group has totals.
This page also has thread::attach, thread::broadcast, thread::cancel, thread::cond, thread::configure, thread::create, thread::detach, thread::errorproc, thread::eval, thread::exists, thread::exit, thread::id, thread::join, thread::mutex, thread::names, thread::preserve, thread::release, thread::rwmutex, thread::send, thread::transfer, thread::unwind, thread::wait.
Subcommands
| Synopsis | What it does |
|---|---|
thread::create ?-joinable? ?-preserved? ?-isolation LEVEL? ?-caps LIST? ?-compute UNITS? ?-meter NAME? ?SCRIPT? |
A new thread that runs SCRIPT, and its id. With no SCRIPT, it waits for messages. -isolation process runs it in a child process, and -isolation vm in a guest of ztcl::vm. -compute caps its compute units, and -meter (capability meter) counts it in a meter of ztcl::meter. -caps gives the thread only the listed capabilities of its creator. |
thread::send ?-async? ?-head? ID SCRIPT ?VAR? |
Runs SCRIPT in the thread and gives its result. With -async, it does not wait. |
thread::broadcast SCRIPT |
Sends SCRIPT to each other thread. |
thread::wait |
Runs the event loop of the thread until thread::release. |
thread::id |
The id of this thread. |
thread::names |
The ids of the threads. |
thread::exists ID |
1 when the thread exists. |
thread::join ID |
Waits for a joinable thread to end. |
thread::preserve ?ID? |
Adds a reference. thread::release removes one, and the thread ends at zero. |
thread::release ?-wait? ?ID? |
Takes a reference away. |
thread::cancel ?-unwind? ID ?RESULT? |
Stops the script that runs in a thread. |
thread::unwind |
Ends thread::wait of this thread. |
thread::exit ?STATUS? |
Ends this thread. |
thread::configure ID ?OPTION? ?VALUE? |
The options of a thread, such as -eventmark. |
thread::errorproc ?PROC? |
The proc for errors of scripts of -async sends. |
thread::transfer ID CHANNEL |
Moves a channel to a thread. thread::detach and thread::attach do it in two steps. |
| `thread::mutex create | destroy |
thread::eval ?-lock MUTEX? SCRIPT |
Runs SCRIPT with a mutex locked. |
Facts
- Capability:
thread. A new interpreter does not have this command. See Limits and capabilities. - Compute cost: one compute unit for the call, and more for the commands that it runs.
Differences from Tcl 8.6
- The isolation levels of
-isolationare from ztcl. See Threads.