Re: Multithreaded Drawing



> I am trying to work out how to set up my multithreaed drawing app of
> real-time data.  I was think that I could run to main loops.  One in the
> main gtkmm thread and a glib::mainloop in my worker thread.  The worker
> thread would have a timeout signal that fires 30 times a second and draws
> the new screen to a buffer.  Once drawing is done it would it would fire off
> a dispatcher signal to the main thread where it draws the buffer to the
> screen.  would this be the right way going about doing this and if so does
> anyone have a quick example on how to accomplish this since I am more book
> smart then practical
>

That's the right way of doing it. Only the main thread should be
drawing stuff into the widgets.

There is another way too: using gdk_threads_init, gdk_threads_enter
and gdk_threads_leave you control which thread is updating the widgets
at any specific time, but sending signals to the main thread is a
cleaner interface than using gdk_threads_enter and gdk_threads_leave
every time you want to update the view

About that quick example you were asking for have a look at this
http://wiki.inkscape.org/wiki/index.php/Using_libsigc%2B%2B_signals.

Here there is another one
http://lsjandysf.spaces.live.com/blog/cns!54FF19028BDE00EA!1113.entry
though it can be too simple


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