Using listeners and signals with Nasal: Difference between revisions

Jump to navigation Jump to search
m
m (→‎Nasal code coupled to the autopilot system: http://flightgear.org/forums/viewtopic.php?f=66&t=15189&p=149376&hilit=#p149376)
Line 15: Line 15:
Keep in mind that listeners are not "background processes" at all - a listener will be triggered by the property tree once a node is accessed, which will invoke the Nasal callback. Timers and listeners are NOT background "processes". They are just invoked by different subsystems, i.e. the property tree (listeners) or the events subsystem (timers). There are other subsystems that can also invoke Nasal handlers, such as the GUI system or the AI code. This all takes place inside the FG main loop (=main thread), not some separate background/worker thread. Which is also the reason why all the Nasal APIs are safe to be used.
Keep in mind that listeners are not "background processes" at all - a listener will be triggered by the property tree once a node is accessed, which will invoke the Nasal callback. Timers and listeners are NOT background "processes". They are just invoked by different subsystems, i.e. the property tree (listeners) or the events subsystem (timers). There are other subsystems that can also invoke Nasal handlers, such as the GUI system or the AI code. This all takes place inside the FG main loop (=main thread), not some separate background/worker thread. Which is also the reason why all the Nasal APIs are safe to be used.


Listeners are not actively "listening" at all - there's no "listener watch" running - instead, it works basically like this:
Listeners are not actively "listening" at all - there's no "listener watch" running - unlike timers, listeners are totally passive instead - it works basically like this:


* register a listener for some property named "foo", to call some Nasal code
* register a listener for some property named "foo", to call some Nasal code

Navigation menu