Any example will be greatly appreciated.
Best regards
Helmut Giese
Tell the other thread to [thread::attach] to the channel.
Donal.
If I understood correctly, you need bidirectional communication
between two threads. I that case:
Take a look at the "fifo2" command of "Memchan" package:
http://www.flightlab.com/~joe/gutter/doc/memchan-2.2.1/fifo2.html
or
"fifo2" command of "tcl::chan::fifo2" package:
http://docs.activestate.com/activetcl/8.5/tcllib/virtchannel_base/fifo2.html
But before this I have to [thread::detach] from it in the thread where
it got created.
Oh, wait - I got it.
Thanks and best regards
Helmut Giese
actually I was working with a fifo2-type channel, but I needed the
link above "to see the light": When it said
---
One particular application for this is communication between threads,
with one half of the pair moved to the thread to talk to.
---
I eventually got it. I do now
lassign [fifo2] slaveIn masterOut
lassign [fifo2] masterIn slaveOut
thread::detach $slaveIn
thread::detach $slaveOut
in the main thread and later a
thread::attach $slaveIn
thread::attach $slaveOut
in the slave thread and everything works now.
Many thanks and best regards
Helmut Giese
Note that fifo channels are bidirectional (full duplex) therefore you
only need one pair of channels.
Well, [thread::transfer] is rather like a [thread::detach] and a
[thread::attach] (in the appropriate threads). In fact, it's so much
like that that I'd call [thread::transfer] a convenience command.
Donal.
> Hello out there,
> from the 'chan' man page
> ---
> Note that this permits the creation of a channel whose two endpoints
Two endpoints. I.e. two channels, which are coupled internally. You
transfer one of the two channels to the other thread. Now data written
by one thread can be read from the other, with the channels internally
doing the transfer across the thread boundaries.
The bad news: This is all stuff you have to write on your own. In the
Tcl handler for the virtual channels.
The good news: This has already been done, and the resulting Tcl code
is in Tcllib. See
http://docs.activestate.com/activetcl/8.5/tcllib/virtchannel_base/fifo2.html
If you want this thing in C, instead via 'chan create', then Memchan
is the package for you, especially its fifo2 command.
--
So long,
Andreas Kupries <akup...@shaw.ca>
<http://www.purl.org/NET/akupries/>
Developer @ <http://www.activestate.com/>
-------------------------------------------------------------------------------
Well, that's even better. Many thanks.
>http://docs.activestate.com/activetcl/8.5/tcllib/virtchannel_base/fifo2.html
>
>If you want this thing in C, instead via 'chan create', then Memchan
>is the package for you, especially its fifo2 command.
yes, TclBliss pointed me to the fifo2 command.
Thanks and best regards
Helmut Giese