beetlebug▾
/

thread detach

Removes a channel from the calling thread for an attach in another thread.

thread::detach CHANNEL

Description

The command thread::detach is the first half of thread::transfer: it removes CHANNEL from the calling thread, and a later thread::attach in a thread of the group puts it in that thread. A detached channel that no thread attaches closes at the end of the group. The examples of this page run with --allow thread --allow channels,file.

Arguments

ArgumentTypeDefaultDescription
CHANNELchannel namerequiredA channel of the calling thread.

Returns

An empty string.

Examples

% set f [open note.txt w]
> puts $f hello
> close $f
> set f [open note.txt]
> thread::detach $f
> set t [thread::create]
> thread::send $t [list thread::attach $f]
> thread::send $t [list gets $f]
hello

Errors

% thread::detach
wrong # args: should be "thread::detach channel"
-errorcode TCL WRONGARGS

% thread::detach nochan
can not find channel named "nochan"
-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