Do signal handlers interrupt script execution?
|
offstar Charming
Registered User
Join date: 26 Dec 2004
Posts: 22
|
01-06-2005 10:25
Will a timer interrupt the execution of code within a script or will it simply wait for the nearest timer interval that nothing is running ( the script is only waiting for events to catch) and then fire?
A simple example would be: If a script got stuck in an infinite loop, would the timer, or for that matter any other signal handlers ever get a chance to run?
|
Adam Zaius
Deus
Join date: 9 Jan 2004
Posts: 1,483
|
01-06-2005 10:26
LSL uses an event stack. The event stack can hold 72 items, and when a script is idle, it remains in a loop processing off the next events in the stack.  (well, as a convenient way of explaining it, the actual process is a lot more complex) So, in answer: It will wait. -Adam
|
Shack Dougall
self become: Object new
Join date: 9 Aug 2004
Posts: 1,028
|
01-06-2005 11:11
I guess you could put in an llSleep() every now and then to give event handlers a chance.
_____________________
Prim Composer for 3dsMax -- complete offline builder for prims and sculpties in 3ds Max http://liferain.com/downloads/primcomposer/
Hierarchical Prim Archive (HPA) -- HPA is is a fully-documented, platform-independent specification for storing and transferring builds between Second Life-compatible platforms and tools. https://liferain.com/projects/hpa
|
offstar Charming
Registered User
Join date: 26 Dec 2004
Posts: 22
|
01-06-2005 11:29
Okay, good. That's what I wanted to hear. I have a complex default state which has a number of different event handlers in it. Seldomly I need to switch to a second state to perform a set of actions which requires a new set of event handlers. I wanted to make sure that if I used a timer to set the default state into a pre-jump sub-state and allowed only some event handlers to continue for a set amount of time that I could actually empty the event queue before jumping and losing my queued events.
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
01-06-2005 13:37
From: Adam Zaius LSL uses an event stack. The event stack can hold 72 items, and when a script is idle, it remains in a loop processing off the next events in the stack.  (well, as a convenient way of explaining it, the actual process is a lot more complex) So, in answer: It will wait. -Adam 72  does it matter what type of event it is? are all events created equal?
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
01-06-2005 13:43
From: Shack Dougall I guess you could put in an llSleep() every now and then to give event handlers a chance. As much as I hate to say it, this is incorrect. llSleep only extends the execution time of the current running event, it doesnt let other handlers get processed. The event queue works by running only one event at a time. All functions within that event only extend that event's execution time. There is no way to somehow pause the execution of the current running event to allow the queue to process more events. ==Chris
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
01-06-2005 13:47
From: Adam Zaius LSL uses an event stack. The event stack can hold 72 items How did you get this information? According to the wiki page on the queue, it can only hold 64 items. ==Chris
|
Shack Dougall
self become: Object new
Join date: 9 Aug 2004
Posts: 1,028
|
01-06-2005 13:54
From: Christopher Omega llSleep only extends the execution time of the current running event, it doesnt let other handlers get processed.
Maybe they should rename the function to llTwiddleThumbs(). 
_____________________
Prim Composer for 3dsMax -- complete offline builder for prims and sculpties in 3ds Max http://liferain.com/downloads/primcomposer/
Hierarchical Prim Archive (HPA) -- HPA is is a fully-documented, platform-independent specification for storing and transferring builds between Second Life-compatible platforms and tools. https://liferain.com/projects/hpa
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
01-06-2005 21:27
If you reall need to interrupt a running script, make another script that runs llResetOtherScript(). Works fairly nicely. I'm not sure if it's actually meant to be used as part of an algorithm, but it sure gets the job done...
Anyway, I initially wondered if LSL was multithreaded or interrupt-driven, but now I'm glad it isn't. Race conditions would be a nightmare.
|