discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

threads and graphics


From: Scott Christley
Subject: threads and graphics
Date: Mon, 4 Aug 2003 11:03:51 -0400

Hello,

I seem to remember this working before but maybe my memory is hazy. If I have a thread which is performing some background calculations and it attempts to lockFocus on a view to do some drawing then I get a seg fault. After some browsing around it seems that the graphics routines rely upon the current thread to store some state data, so obviously that data is not present with the background thread. Does anybody have a suggestion on how to handle this?

My application has the standard Model-View-Controller design, and the model is a complicated simulation which will be run in a separate thread. The idea being that the GUI is still responsive to the user while the simulation is running, and state changes within the simulation are reflected to the user through various graphical displays. Now I can conceptualize how to split the work; the View has to do all of the drawing in the main thread, yet it is the Model which knows when its state has changed and thus knows when the graphical displays need to be updated. However the Model cannot call the View directly to do the update because it is running in the wrong thread. The Model needs to 'signal' the main thread in some way so that the View can do the update. The difficulty I have with the signaling concept is that the Model is composed of many pieces, so a state change to one piece would only entail a small change to the graphic display; I don't want to use a generic signal which updates all of the graphical displays. This seems to imply that I would have to design an elaborate set of signals to get the granularity of display change that I desire; something that I don't really want to do. Hopefully somebody has a better idea?

Please send email to me directly as I am not on the list.

thanks
Scott





reply via email to

[Prev in Thread] Current Thread [Next in Thread]