beetlebug▾
/

thread configure

Reads or sets the options of a thread.

thread::configure ID
thread::configure ID OPTION
thread::configure ID OPTION VALUE ?OPTION VALUE ...?

Description

The command thread::configure gives the options of the thread ID and their values as a list, gives the value of one OPTION, or sets one or more options. A set parses each value first, so an error leaves the thread as it was.

Arguments

ArgumentTypeDefaultDescription
IDthread idrequiredThe thread.

Options

OptionTypeDefaultDescription
-eventmarkinteger, 0 or more0Makes an asynchronous send wait while the queue of the thread has N messages.
-unwindonerrorboolean0Ends the thread after a sent script with an error.
-errorstateboolean0Accepted for the Thread package, and always 0.

-eventmark N

Makes an asynchronous send wait while the queue of the thread has N messages.

With N above 0, a thread::send -async to the thread waits while its queue has N messages. With 0, the queue has no such bound, up to max_queue of the group.

% set t [thread::create]
> thread::configure $t -eventmark 5
> thread::configure $t -eventmark
5
% thread::configure [thread::id] -eventmark -1
expected a count but got "-1"
-errorcode NONE

% thread::configure [thread::id] -eventmark x
expected integer but got "x"
-errorcode TCL VALUE NUMBER

-unwindonerror BOOLEAN

Ends the thread after a sent script with an error.

With a true value, the thread ends after a script of thread::send gives an error.

% set t [thread::create]
> thread::configure $t -unwindonerror yes
> thread::configure $t -unwindonerror
1
% thread::configure [thread::id] -unwindonerror maybe
expected boolean value but got "maybe"
-errorcode TCL VALUE NUMBER

-errorstate BOOLEAN

Accepted for the Thread package, and always 0.

A set of -errorstate checks the value and has no other effect, and a read gives 0.

% thread::configure [thread::id] -errorstate 1
> thread::configure [thread::id] -errorstate
0
% thread::configure [thread::id] -errorstate maybe
expected boolean value but got "maybe"
-errorcode TCL VALUE NUMBER

Returns

A list of options and values, one value, or an empty string for a set.

Examples

% set t [thread::create]
> thread::configure $t
-eventmark 0 -unwindonerror 0 -errorstate 0

% set t [thread::create]
> thread::configure $t -eventmark 2 -unwindonerror 1
> thread::configure $t
-eventmark 2 -unwindonerror 1 -errorstate 0

Errors

% thread::configure
wrong # args: should be "thread::configure threadlId ?optionName? ?value? ?optionName value?..."
-errorcode TCL WRONGARGS

% thread::configure [thread::id] -bogus
bad option "-bogus", should be one of -eventmark, -unwindonerror or -errorstate
-errorcode NONE

% thread::configure tid0x99
thread "tid0x99" does not exist
-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