I am new to Threads, so guys can u please give me how/where to start
off. Provide some good links, sample programs for Tcl Threads will be
good.
Thanks,
RR.
A good start would be to first make sure you really need them.
Are you familiar with the event-driven approach ? ([vwait] [fileevent]
[after]...)
-Alex
On Sep 22, 8:35 am, Alexandre Ferrieux <alexandre.ferri...@gmail.com>
wrote:
The 'traditional' way in Tcl is to use the built in event loop to
schedule small snippets of work. You might be familiar with that model
from GUI toolkits.
See the links at: http://wiki.tcl.tk/1527
The second tradional way would be to use multiple processes, connected
with pipes or sockets.
But as you asked, the Thread package provides multihreading to Tcl
scripts, but in a different way than for many other languages. Its more
'message passing' based than 'shared state' based multithreading.
Some links for a start:
http://wiki.tcl.tk/2770
http://wiki.tcl.tk/_ref/3829
Michael
1) Arrange for function f to be called when new data arrive from a
child:
set ff [open "|somecommand" r]
fileevent $ff readable f
2) Arrange for function g to be called $x milliseconds later:
after $x g
3) Arrange for function h to be called whenever widget .w is clicked:
bind .w <Button-1> h
All these just register callbacks. Now here is the real worker, from
within whom the callbacks are called:
vwait forever
(or just fall back from the main script in the case of wish)
The mere combination of the three primitives above generates a huge
spectrum of possibilities.
-Alex
Thanks guys, Will start looking into these and get to know if i need
further queries.
Thanks,
-RR