Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tcl Threads

8 views
Skip to first unread message

RR

unread,
Sep 22, 2007, 2:56:51 AM9/22/07
to
Hi All,

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.

Alexandre Ferrieux

unread,
Sep 22, 2007, 3:35:05 AM9/22/07
to

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

RR

unread,
Sep 22, 2007, 10:45:06 AM9/22/07
to
Not much, so that can u suggest mee some good link for reading with
some sample examples.

On Sep 22, 8:35 am, Alexandre Ferrieux <alexandre.ferri...@gmail.com>
wrote:

Michael Schlenker

unread,
Sep 22, 2007, 1:51:30 PM9/22/07
to
RR schrieb:
Tcl has two approaches to concurrency (or actually three if you count
processes).

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

Alexandre Ferrieux

unread,
Sep 22, 2007, 2:16:44 PM9/22/07
to
On Sep 22, 4:45 pm, RR <meetra...@gmail.com> wrote:
> > Are you familiar with the event-driven approach ? ([vwait] [fileevent]
> > [after]...)
> Not much, so that can u suggest mee some good link for reading with
> some sample examples.


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

RR

unread,
Sep 23, 2007, 3:33:54 AM9/23/07
to
On Sep 22, 7:16 pm, Alexandre Ferrieux <alexandre.ferri...@gmail.com>
wrote:

Thanks guys, Will start looking into these and get to know if i need
further queries.

Thanks,
-RR

0 new messages