paulie Femto
Into the dark
Join date: 13 Sep 2003
Posts: 1,098
|
04-19-2005 08:42
In LSL, why do event handlers wait for loops to complete? If LSL is going to handle events, shouldnt events be handled -when- they happen, not later?
_____________________
REUTERS on SL: "Thirty-five thousand people wearing their psyches on the outside and all the attendant unfettered freakishness that brings."
|
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
|
04-19-2005 09:26
From: paulie Femto In LSL, why do event handlers wait for loops to complete? If LSL is going to handle events, shouldnt events be handled -when- they happen, not later? I imagine that is to reduce the complexity. i.e. handling events at the end of each function call when the state of the script is clear, instead of having to attempt thread-safe code that synchronizes all the script globals (oh my, just think about that makes me feel all faint).... 
_____________________
http://slurl.com/secondlife/Together
|
Jack Digeridoo
machinimaniac
Join date: 29 Jul 2003
Posts: 1,170
|
04-19-2005 09:59
In OSMP creating a virtual machine and calling an event is basically a call to an external library, LUA for OSMP.
The VM's in LUA are able to handle multithreading, Azelda has made it so only one function can be running. The VM can report if it's busy and events are queued in this case.
// main loop // check for events, add them to a queue // loop through queued events and send them to free vm's
VM's are created in separate threads. If a VM is busy, in loop for instance, the event is still in the queue and the script engine will try to deliver the event the next time around.
Azelda could explain it better, he wrote everything I'm trying to describe here.
If you called a timer event faster than it was able to complete, that could cause problems. It would be very hard, to sync globals in LUA. I'm not even sure if LUA will allows for creating instances of the same VM. The lua stack would have problems I'm guessing.
I don't think SL uses the LUA engine, but it sounds like are similar.
_____________________
If you'll excuse me, it's, it's time to make the world safe for democracy.
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
04-19-2005 10:07
Fortunately, you can use a second script buffer to break the loop. For example. Script number one: default { state_entry() { llSetStatus(STATUS_PHANTOM,TRUE); while(llGetStatus(STATUS_PHANTOM)) { } } }
Script two could break the loop by doing this: default { touch_start(integer total_number) { llSetStatus(STATUS_PHANTOM,FALSE); } } Multiple buffer scripting is fun! 
_____________________
---
|
Chris Wilde
Custom User Title
Join date: 21 Jul 2004
Posts: 768
|
04-19-2005 10:33
From: Jeffrey Gomez Fortunately, you can use a second script buffer to break the loop. Multiping bugger scripting is fun!  Good idea!
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
04-19-2005 10:54
Fixed the text. Don't ask me how that one happened. 
_____________________
---
|