aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_runner.c
diff options
context:
space:
mode:
Diffstat (limited to 'LuaSL/src/LuaSL_runner.c')
-rw-r--r--LuaSL/src/LuaSL_runner.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/LuaSL/src/LuaSL_runner.c b/LuaSL/src/LuaSL_runner.c
index a59855d..5bb5e7a 100644
--- a/LuaSL/src/LuaSL_runner.c
+++ b/LuaSL/src/LuaSL_runner.c
@@ -159,3 +159,96 @@ void runnerTearDown(gameGlobals *game)
159// TODO - this is what hangs the system. 159// TODO - this is what hangs the system.
160 sched_join_workerthreads(); 160 sched_join_workerthreads();
161} 161}
162
163
164/* What we need to do, and how we might do it.
165 *
166 * Get configuration info.
167 *
168 * Some of the configuration info we need is tucked away in OpenSim .ini files. So we have to read that.
169 * Eet is probably not so useful here, as we would have to write a UI tool, and there's no UI otherwise.
170 *
171 * Multi task!
172 *
173 * Luaproc starts up X worker threads. Each one takes the next ready Lua state and runs it until it blocks waiting for a channel message, or yields.
174 * The current mainloop waits for events and commands from the message channel, executes them, then goes back to waiting.
175 * So that is fine in general, so long as the LSL event handlers actually return in a reasonable time.
176 * We need to be able to yield at suitable places, or be able to force a yield. Both without slowing things down too much.
177 *
178 * Watchdog thread.
179 *
180 * It's easy enough to have a watchdog thread wake up every now and then to check if any given Lua state has been hogging it's CPU for too long.
181 * The hard part is forcing Lua states to yield cleanly, without slowing performance too much.
182 *
183 * Identifying scripts.
184 *
185 * We need to be able to identify scripts so that messages can get to the right ones. Also the objects they are in.
186 * And do it all in a way that OpenSim is happy with.
187 * Copies of the same script in the same prim would have the same UUID, but different name, though they would run independently.
188 * Copies of the same script in different prims could have the same UUID AND the same name.
189 *
190 * Script start, stop, reset.
191 *
192 * Scripts and users have to be able to start, stop, and reset scripts.
193 * Users have to be able to see the start / stopped status of scripts from the viewer.
194 * Which means if the script does it, we have to tell OpenSim.
195 * Naturally, if OpenSim does it, it has to tell us.
196 * Should be able to do both by passing textual Lua function calls between OpenSim and LuaSL.
197 *
198 * Event handling, llDetect*() functions.
199 *
200 * OpenSim will generate events at random times and send us relevant information for llDetect*() functions and the handler calls.
201 * These should come through the scripts main loop eventually.
202 *
203 * Send messages from / to OpenSim and ROBUST.
204 *
205 * ROBUST uses HTTP for the communications, and some sort of XML, probably XML-RPC.
206 * OpenSim has some sort of generic mechanism for talking to script engines in C#. I want to turn that into a socket based, pass textual Lua function calls, type system.
207 * That assumes C# has some sort of semi decent introspection or reflection system.
208 * The scripts main loop can already deal with incoming commands as a string with a Lua function call in it.
209 *
210 * Send messages from / to Lua or C, and wait or not wait.
211 *
212 * Luaproc channels are distinct from Lua states, but some Lua state has to create them before they can be used.
213 * On the other hand, looks like broadcasting messages is not really catered for, it's first come first served.
214 * luaproc.send() can send multiple messages to a single channel. It blocks if no one is listening.
215 * This was done to simplify things for the luaproc programmers, who suggest creating more Lua states to deal with asynchronous message sending.
216 * luaprog.receive() gets a channel message. It can block waiting, or not block.
217 * I already hacked up C code to send and not block. I might have broken the luaproc.send() ability to send multiple messages.
218 * Before I hacked it up, actual message sending was done by copying the contents of the sending Lua states stack to the receiver states stack.
219 * This is the simple method for the luaproc programmers, as both states are in the context of a luaproc call, so both stacks are available.
220 * My hacked up version either takes one message from the sender, or is passed one from C. The C call just returns if there is no one waiting on that channel.
221 * luaproc.send() cals that C function after taking a single message from the stack, and block waits as usual if the C call cannot deliver.
222 * Don't think there is C to receive messages, luaproc seems to be lacking entirely in C side API.
223 * Edje messages might have to be used instead, or some hybrid.
224 *
225 * Time and timers, plus deal with time dilation.
226 *
227 * Various LSL functions deal with time, that's no problem.
228 * Some might deal with time dilation, which means dealing with that info through OpenSim.
229 * There is a timer event, which should be done through ecore timers and whatever message system we end up with.
230 * Finally, a sleep call, which can be done with ecore timer and messages to.
231 *
232 * Deal directly with MySQL and SQLite databases.
233 *
234 * The script engine can run on the same computer as the sim server, that's how OpenSim does stuff. So we can directly access the database the sim server has, which gives us access to sim object metadata.
235 * Changing that metadata might require us to inform OpenSim about the changes. It's entirely possible that different changes do or do not need that.
236 * Esskyuehl may be suitable, though it's still in the prototype stage.
237 *
238 * Serialise the script state, send it somewhere.
239 *
240 * Lua can generally serialise itself as as a string of code to be executed at the destination. There might be some C side state that needs to be take care of as well. We shall see.
241 *
242 * Email, HTTP, XML-RPC?
243 *
244 * LSL has functions for using these as communications methods. We should implement them ourselves eventually, but use the existing OpenSim methods for now.
245 * Note that doing it ourselves may cause issues with OpenSim doing it for some other script engine.
246 * Azy might be suitable, but it's also in prototype.
247 *
248 * Object inventory "cache".
249 *
250 * This code currently pretends that there is a local file based sim object store available.
251 * I think it would be a good idea to abuse the OpenSim cache system to produce that file based object store.
252 * It will help with the "damn OpenSim's asset database has to be a bottomless pit" monster design flaw.
253 *
254*/