Dear Mark, Why don't you use a port? This abstraction is designed for that kind of usage. Make the first thread send every decoded tuple on the port, and the other thread just reads the stream of tuples. The second thread will naturally block when no data is available.
Raphael On Mon, Feb 15, 2010 at 3:45 PM, mark richardson <[email protected]>wrote: > Hi, > > I wonder if anyone could help me with this? > I have a socket connection which accepts tuples in string form. I want to > be able to access each tuple in turn, suspending execution when waiting for > further input on the socket. The tuples might arrive singly or in multiples > and because they may be of variable size (in terms of their string > representation), I can't use fixed length reading of the socket. > What I have done so far is to create a thread which continually copies data > read from the socket, converting it to actual tuples and then adding it to > the end of a queue implemented on top of a cell - basically a buffer. I have > a couple of simple push/pop functions to manage the queue. > The problem I am stuck with now is how to make execution suspend if the > content of the cell is nil (and how to resume when more data is added to the > cell). > > I'd be very grateful if anyone can offer any advice on this, either how to > implement it the way I've suggested or a better way to achieve the same > result. > > Thanks in advance > > Mark > > > > _________________________________________________________________________________ > mozart-users mailing list > [email protected] > http://www.mozart-oz.org/mailman/listinfo/mozart-users >
_________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users
