Timing of IRuntime Function Calls
2 posters
Page 1 of 1
Timing of IRuntime Function Calls
According to the documentation, functions including SetPower,SetBrake,SetReverser,KeyDown,KeyUp,HornBlow,DoorChange,SetSignal and SetBeacon can be called at "any time".
Will it affect the timing (cause operation to be delayed for a frame, for example) if a plugin internally uses an event queue (so that these function calls push events to a queue, which later gets all processed in Elapsed, for a more convenient access to parameters inside ElapseData)?
And in which aspect will handling events like this have disadvantage on?
Will it affect the timing (cause operation to be delayed for a frame, for example) if a plugin internally uses an event queue (so that these function calls push events to a queue, which later gets all processed in Elapsed, for a more convenient access to parameters inside ElapseData)?
And in which aspect will handling events like this have disadvantage on?
Re: Timing of IRuntime Function Calls
I don't believe it should, although this can get a little complicated; It really depends on exactly what you're trying to do & what you're expecting to happen.
A SetPower, SetBrake etc. call is made by the simulation whenever the internal change is made. Depending on what actually triggered this, it may be before or after the processing of the Elapse call.
For example, comparing the brake / power notch in the ElapseData to that set by the SetBrake / SetPower function may be off for a single elapse call, but I can't see what difference this really makes.
In practice, you're talking milliseconds between calls, and you should be fine handling whatever in the next Elapse call.
Don't forget also that the Elapse call is blocking:
https://github.com/leezer3/OpenBVE/blob/master/source/OpenBVE/System/Plugins/NetPlugin.cs#L148
A SetPower, SetBrake etc. call is made by the simulation whenever the internal change is made. Depending on what actually triggered this, it may be before or after the processing of the Elapse call.
For example, comparing the brake / power notch in the ElapseData to that set by the SetBrake / SetPower function may be off for a single elapse call, but I can't see what difference this really makes.
In practice, you're talking milliseconds between calls, and you should be fine handling whatever in the next Elapse call.
Don't forget also that the Elapse call is blocking:
https://github.com/leezer3/OpenBVE/blob/master/source/OpenBVE/System/Plugins/NetPlugin.cs#L148
zbx1425 likes this post
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|