sysAddObjRecurringTimerEvent question (for George)

Freeform discussion about anything related to modding Transcendence.
Post Reply
Apemant
Commonwealth Pilot
Commonwealth Pilot
Posts: 94
Joined: Mon Dec 03, 2007 12:51 pm

I guess only George could really answer this question...

How 'dangerous' is sysAddObjRecurringTimerEvent? How likely to cause a racing condition and crash the game?

Are there multiple threads which execute scripts or they are all in the same thread, i.e. guaranteed to execute one command at the time? Suppose I have an event that gets called every 15 ticks. Now what if I manually invoke a certain command which wants to 'cancel' the above recurring event, but I invoke that command on the very same tick when this event is scheduled to trigger. Will those scripts get executed one after another in the same thread, or simultaneously, in two separate threads? And if they are in the same thread, which one will be called first - or it is undetermined?

I have a nasty feeling that those timer events have a habit of crashing the game but I'm not sure, maybe I'm making some bugs elsewhere...
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Apemant wrote:I guess only George could really answer this question...

How 'dangerous' is sysAddObjRecurringTimerEvent? How likely to cause a racing condition and crash the game?

Are there multiple threads which execute scripts or they are all in the same thread, i.e. guaranteed to execute one command at the time? Suppose I have an event that gets called every 15 ticks. Now what if I manually invoke a certain command which wants to 'cancel' the above recurring event, but I invoke that command on the very same tick when this event is scheduled to trigger. Will those scripts get executed one after another in the same thread, or simultaneously, in two separate threads? And if they are in the same thread, which one will be called first - or it is undetermined?

I have a nasty feeling that those timer events have a habit of crashing the game but I'm not sure, maybe I'm making some bugs elsewhere...
The execution engine is single-threaded, so only one script will execute at a time. I don't know of any race conditions right now.

One issue to watch out for is across scripts. For example, imagine a DockScreen with a script in <Initialize> and a script in <Action>. You have to allow for the possibility that another script could run between the <Initialize> and the <Action>.

If you are having problems with call order, you might try adding some (dbgLog) or (dbgOutput) calls to see what is getting called.
Apemant
Commonwealth Pilot
Commonwealth Pilot
Posts: 94
Joined: Mon Dec 03, 2007 12:51 pm

george moromisato wrote:The execution engine is single-threaded, so only one script will execute at a time. I don't know of any race conditions right now.
Thanks, this answers a lot... it definitely means I made some bug elsewhere. Will do some more debugging I guess.

Good to know I don't have to fear those timer events...
Post Reply