diff options
-rw-r--r-- | examples/vwaitsignal.tcl | 26 | ||||
-rw-r--r-- | jim_tcl.txt | 7 |
2 files changed, 31 insertions, 2 deletions
diff --git a/examples/vwaitsignal.tcl b/examples/vwaitsignal.tcl new file mode 100644 index 0000000..d59879a --- /dev/null +++ b/examples/vwaitsignal.tcl @@ -0,0 +1,26 @@ +# In lieu of some proper unit tests, this example +# checks that vwait can be interrupted by handled signals + +set f [open "/dev/urandom" r] + +set count 0 + +$f ndelay 1 + +signal handle SIGALRM + +$f readable { + incr count [string bytelength [read $f 100]] +} + + +set start [clock millis] + +# Even though nothing sets 'done', vwait will return on the signal +alarm 0.5 +vwait -signal done + +set end [clock millis] +puts "Read $count bytes and received [signal check -clear] after $($end - $start)ms" + +$f close diff --git a/jim_tcl.txt b/jim_tcl.txt index 19de99b..3adf900 100644 --- a/jim_tcl.txt +++ b/jim_tcl.txt @@ -59,6 +59,7 @@ Changes between 0.81 and 0.82 3. Add support for `socket -async` 4. The handles created by `socket pty` now make the replica name available via 'filename' 5. `info frame` now returns a (largely) Tcl-compatible dictionary, and supports 'info frame 0' +6. `vwait -signal` is now supported Changes between 0.80 and 0.81 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -5117,12 +5118,14 @@ Time-based execution is also available via the eventloop API. the type of the event. An error occurs if +'id'+ does not match an event. -+*vwait* 'variable'+:: ++*vwait ?-signal?* 'variable'+:: A call to `vwait` enters the eventloop. `vwait` processes events until the named (global) variable changes or all event handlers are removed. The variable need not exist beforehand. If there are no event handlers defined, `vwait` - returns immediately. + returns immediately. If +'-signal'+ is specified, `vwait` will + also quit if a handled signal occurs. In this case, `signal check -clear` + can be used to check for the signal that occurred. +*update ?idletasks?*+:: A call to `update` enters the eventloop to process expired events, but |