That performance-issue would be restricted to Tcl 8.0, and would still be flawed with the byte vs char issue...
In any case, I fail to see how that is related to the topic.
@tmyoungjr:
I believe
user posted a very flexible throttling-mechanism that could easily be adopted to your script.
Check this post:
http://forum.egghelp.org/viewtopic.php?p=75097#75097
arfer's approach is interresting, yet may cause the script to stop responding should any I/O-errors occur during the reading. Would probably be a good idea to move the utimer to the top of the proc.
Also worth mentioning, is that this will keep resetting the bind-counter every time it triggers.
A third option would be to simply use timestamps, removing the need for any timers or cleanup. Example posted below:
Code: Select all
proc throttle {id time} {
if {[info exists ::throttle($id)] && $::throttle($id) > [clock seconds]} {
return 0
}
set ::throttle($id) [expr [clock seconds] + $time]
return 1
}
proc myproc {} {
if {[throttle "theid" 60]} {
#we're ok, do the good stuff here
} {
#still throttle'd, do nothing
return 0
}
}