aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2023-02-01 14:33:41 +1000
committerSteve Bennett <steveb@workware.net.au>2023-02-13 10:44:10 +1000
commit6778c36ca8204d45fdaef06cf54c094f75689e26 (patch)
tree3f1a0c76ee29b1c7020be606868f91e14917544f
parent97c305635eb1552ad373c7e0a835b6069fd79312 (diff)
downloadjimtcl-6778c36ca8204d45fdaef06cf54c094f75689e26.zip
jimtcl-6778c36ca8204d45fdaef06cf54c094f75689e26.tar.gz
jimtcl-6778c36ca8204d45fdaef06cf54c094f75689e26.tar.bz2
vwait -signal docs and test script
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r--examples/vwaitsignal.tcl26
-rw-r--r--jim_tcl.txt7
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