Callbacks: Difference between revisions

No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:


{{Main article|Howto:Troubleshooting Nasal Callbacks}}
{{Main article|Howto:Troubleshooting Nasal Callbacks}}
{{Cautio|Improper use of timers and listeners is one of the most common causes for FlightGear performance issues, because function callbacks (code) may be registered to be triggered/executed more often than required, this problem is not specific to [[Nasal]] code written  by aircraft developers, but also C++ code written by FlightGear core developers, it's been the source of major resource leaks in FlightGear, causing severe stuttering and performance degradation over time.}}
{{Caution|Improper use of timers and listeners is one of the most common causes for FlightGear performance issues, because function callbacks (code) may be registered to be triggered/executed more often than required (potentially, several times per frame), this problem is not specific to [[Nasal]] code written  by aircraft developers, but also C++ code written by FlightGear core developers, it's been the source of major resource leaks in FlightGear, causing severe stuttering and performance degradation over time.}}


The one thing that both timers and listeners have in common is that they're event handlers, i.e. mechanisms that allow custom code to be executed whenever a certain event is triggered, such as a configurable timer expiring and/or a property being updated/modified.
The one thing that both timers and listeners have in common is that they're event handlers, i.e. mechanisms that allow custom code to be executed whenever a certain event is triggered, such as a configurable timer expiring and/or a property being updated/modified.
Line 37: Line 37:


== Timers ==
== Timers ==
{{See also|Nasal Events}}


'''Timers''' are a way to register recurring tasks to be executed repeatedly. This is accomplished using the FlightGear event manager. Timers are the most common method for running Nasal callbacks (functions), the other being [[Listeners]].
'''Timers''' are a way to register recurring tasks to be executed repeatedly. This is accomplished using the FlightGear event manager. Timers are the most common method for running Nasal callbacks (functions), the other being [[Listeners]].