Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » Simulation in its own thread.
Simulation in its own thread. [message #8016] Sun, 04 February 2007 13:31 Go to next message
yeus is currently offline  yeus
Messages: 19
Registered: October 2006
Promising Member
Ok I'll explain what I want to do first:

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 ^^) Smile
Re: Simulation in its own thread. [message #8017 is a reply to message #8016] Sun, 04 February 2007 14:01 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
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.

Bas
Re: Simulation in its own thread. [message #8089 is a reply to message #8017] Tue, 06 February 2007 20:45 Go to previous message
yeus is currently offline  yeus
Messages: 19
Registered: October 2006
Promising Member
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 Smile

greetings, Tom
Previous Topic: SSLSocket VerifyPeer -> how to set trusted CAs?
Next Topic: MT & File Access
Goto Forum:
  


Current Time: Thu Mar 28 11:00:39 CET 2024

Total time taken to generate the page: 0.01027 seconds