beetlebug▾
/

thread preserve

Adds one to the reference count of a thread.

thread::preserve ?ID?

Description

The command thread::preserve adds one to the reference count of the thread ID, or of the calling thread, and gives the new count. A new thread has the count 0, or 1 with -preserved. Each thread::release subtracts one, and at 0 the thread::wait of the thread returns.

Arguments

ArgumentTypeDefaultDescription
IDthread idnoneThe thread, by default the calling thread.

Returns

The new reference count.

Examples

% set t [thread::create]
> thread::preserve $t
> thread::preserve $t
2

Errors

% thread::preserve tid0x99
thread "tid0x99" does not exist
-errorcode NONE

% thread::preserve nothread
invalid thread handle "nothread"
-errorcode NONE

Facts

Capability
thread. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also