I wrote a Simulation which - right now - is running as console application. The Simulation is very efficient, so i dont want to use any Upp related stuff in it.
Now I want a GUI to show the process of the simulation (its a fluid simulation). For the simulation to stay efficient I want to run it in its own thread (of course I also want the User to be able to use the GUI while the simulation is running).
I had a look a the MTGui Example, but my problem with this approach is, that I just have too much data, to send copies forth and back between GUI and Simulation thread.
So I do need shared memory, But How do i do that? Are there any-"mutex-like" classes in Upp? I saw something like "Criticalsection", but can not figure out how to use it.
greetings Tom.
(Any help would be appreciated, i'll give the program to the community after its done ^^)
give your app a CriticalSection, lets call it data:
CriticalSection data;
locking it is done by
data.Enter(); //enter the critical section
data.Leave(); //leave the critical section
CriticalSection::Lock __(data); //lock the critical section until destroyed eg create it at beginnin of a method and the whole method is secured for access
But i am not sure wether this helps you, because both apps have to use the same CriticalSection.
would it be possible to derive the Simulation (If I have an interface-class to the simulation) from a thread and a critical section and locking itself, while doing any action? An object trying to get acces to the simulation would then need to wait until the simulation has through its current loop... After this the object ges access to the simulation, and after done with reading, simulation starts all over....
sorry dont have upp here right now. that's why i'm asking whether this is possible nd not just trying it out