Posted 14 September 2013 - 05:24 AM
Title: Passing environment into shell
Im not sure, maybe somebody did already ask for this. I am doing a program that should handle eventHandlers in more fashionate way. I found out that there sould be two ways how to do it. 1. bypass all calls that make thread yield and do the eventHandling before that. (not sure if I can do it globally) (or do I, when does the invocations get flushed???)
2. have a parallel program that handles all events and passes them in a table, which is then used by doEvents function. But I had troubles with passing environment variebles through os.run(env, "rom/programs/shell"). I didn't have problems passing it into any other programs. I kind of got stuck here and am thinking of redoing it into the first variant.
Is it so that shell creates its own environment and flushes everything passed by the first parameter??
Eventually what are all the calls that make the main thread yield??
Well and when I try to do it on a single thread I want to put the "endOfInvocs" event to know when to stop listening the events, but somehow it doesnt work.
Im not sure, maybe somebody did already ask for this. I am doing a program that should handle eventHandlers in more fashionate way. I found out that there sould be two ways how to do it. 1. bypass all calls that make thread yield and do the eventHandling before that. (not sure if I can do it globally) (or do I, when does the invocations get flushed???)
2. have a parallel program that handles all events and passes them in a table, which is then used by doEvents function. But I had troubles with passing environment variebles through os.run(env, "rom/programs/shell"). I didn't have problems passing it into any other programs. I kind of got stuck here and am thinking of redoing it into the first variant.
Is it so that shell creates its own environment and flushes everything passed by the first parameter??
Eventually what are all the calls that make the main thread yield??
Well and when I try to do it on a single thread I want to put the "endOfInvocs" event to know when to stop listening the events, but somehow it doesnt work.
local function listenSingle()
print("started listening")
local Args = {}
os.queueEvent("EndOfInvocs") -- none of read, sleep or os.pullEvent and other yielding calls should be called here
Args[1] = _pullEvent() -- otherwise the program ends in infinite loop
local eventStr = Args[1]
while eventStr ~= "EndOfInvocs" do
print(eventStr)
local event = StringToEvent(eventStr)
table.remove(Args,1)
for i,handler in pairs(_Events[event].handlers) do
table.insert(_invocations,{func = handler.func,Args = Args})
end
Args = {_pullEvent()}
eventStr = Args[1]
end
end