lua-users home
lua-l archive

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


Hello,

I work on laboratory equipment control system. In that system we use
Lua as tool for describing control sequences:

--set pin #12 to one state (5v), wait for signal on pin #10, reset pin #12
function F()
 pins:OnPin(12,true);
  while(vipins:GetPinInStatus(10)==false) do
    coroutine.yield();
  end
 vipins:OnPin(12,false);
end;

We need control many pins concurrently, so we use coroutines:
Fco=coroutine.create(F);
In other words, we use coroutines, because of concurrent waiting.

Up until now we've been working with small numbers of coroutines
(1...5) and all code that we need, we generate in such coroutines.
Now, we have to implement interpreter mode in our system and so
operator could send new commands *after* early created coroutines have
been run. So we have to create new coroutine for every new operator
command (because AFAIK we can't add Lua code to early created
coroutine)

The question - Is it normal to have 500...1000 coroutines in program ?
Don't that cause system resources leak ?

Thank you,
Petrov Alexander

-- 
View this message in context: http://www.nabble.com/Lua-coroutine-using-tp20190751p20190751.html
Sent from the Lua - General mailing list archive at Nabble.com.