20,741
edits
m (https://forum.flightgear.org/viewtopic.php?f=30&t=37938&p=373471&hilit=nasal+threading#p373471) |
m (https://sourceforge.net/p/flightgear/mailman/message/34790212/) |
||
Line 1: | Line 1: | ||
{{cquote|in a typical airliner, you have several EFIS screens, each with its own, largely independent Nasal code to drive a canvas surface for it; and then you have various subsystems, many of which are also mostly independent. They could all run in parallel, coordinating their activities via a thread-safe property tree.<ref>{{cite web |url=https://forum.flightgear.org/viewtopic.php?p=373471#p373471|title=<nowiki>Nasal, multitreading and performance</nowiki>|author=tdammers|date= Tue Sep 08, 2020 4:23 am}}</ref>|tdammers}} | {{cquote|in a typical airliner, you have several EFIS screens, each with its own, largely independent Nasal code to drive a canvas surface for it; and then you have various subsystems, many of which are also mostly independent. They could all run in parallel, coordinating their activities via a thread-safe property tree.<ref>{{cite web |url=https://forum.flightgear.org/viewtopic.php?p=373471#p373471|title=<nowiki>Nasal, multitreading and performance</nowiki>|author=tdammers|date= Tue Sep 08, 2020 4:23 am}}</ref>|tdammers}} | ||
{{cquote|we should implement multi-processing or multi-threading using message passing, and mirrors of the property tree. (And hence no concerns about locking at all!) | |||
Rough design is: | |||
* main thread has existing property tree | |||
* other threads have read only copy (mirror) of their parts property tree (subscription model, so only the parts they have requested) | |||
* new code synchronizes property changes from the master to the copies once per frame or some other interval | |||
* other threads can ONLY interact with the main thread via the command API (which can be serialised into messages, and queued to be passed back to the main thread). | |||
(so on a non-main thread, when you try and do ‘setValue’ on a property, we queue a ‘property-assign’ command and send it to the main thread) | |||
<ref>{{cite web |url=https://sourceforge.net/p/flightgear/mailman/message/34790212/|title=<nowiki>A FGPythonSys implementation: The embedded Python interpreter as a FlightGear subsystem.</nowiki>|author=James Turner|date= 2016-01-23 21:02:02}}</ref>|James Turner}} | |||