TIP 434: Specify Event Sources for 'vwait'

Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
Author:		Jos Decoster <jos.decoster@gmail.com>
State:		Draft
Type:		Project
Tcl-Version:	8.6
Vote:	Pending
Created:	26-Feb-2015


This TIP proposes to extend the vwait Tcl command so the event sources can be specified, as is possible with the Tcl_DoOneEvent C command.


In some situations it can be required not to wait for specific event sources or to wait for specific events sources only. You might want the program to only react on timer events, and not on file or window events. You can write your own version of the Tcl_VwaitObjCmd command in C, and call Tcl_DoOneEvent with the flags you need. Making it possible to specify the event sources, i.e. the arguments for the call to Tcl_DoOneEvent within Tcl_VwaitObjCmd, from the Tcl vwait command would make this functionality available from the Tcl lebvel.


This document proposes to add optional arguments to the vwait command. If these arguments are not specified, the current event source TCL_ALL_EVENTS will be used. If the optinal arguments are specified, they are the event sources to be passed to Tcl_DoOneEvent within Tcl_VwaitObjCmd. The flags set with the optinal arguments will be or-ed. Possible flags are corresponding to the flags for the Tcl_DoOneEvent command:

Example: wait until variable a is written and only allow timer events to be processed:

 vwait a -timer


A possible alternative is to add support for a -events argument.

A -dont_wait argument is not added, a call to update will have the same effect.


No incompatibilities are introduced.

Reference Implementation

A reference implementation is available.


This document has been placed in the public domain.