lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi all,

I'm stuck on a little problem using Lua Lanes. It's the first time
I've actually tried to use it other than just playing around, but now
that I try I just can't get it to work the way I want.

In this case I have a producer and consumer, I use a linda to pass
data from one to the other, this works fine. However I also want to
keep track of how many lines are awaiting processing by a consumer.
For this I'm looking for an atomic counter which can be incremented
and decremented.

According to the docs, Lanes provides exactly this through its
'genatomic' API method. However the code example I link below doesn't
seem to work - the processor ends up hanging on the queued_count(-1)
call. I tried using locks manually but also had problems, as described
in the comments.

The code is at: http://matthewwild.co.uk/uploads/lanetest.lua

The script needs lines for input, to run you can try:

 $ yes | lua ./lanetest.lua

At least on my PC it hangs very shortly after starting (well, the
processor does, the reader seems happy).

Is Asko or anyone familiar with Lanes able to explain what's going
wrong, or even better, provide me with pointers to working Lanes code?
It's proving hard to come by via Google.

Many thanks,
Matthew