Re: Multithreaded gtk apps

On 14 January 2013 04:46, Andy Spencer <andy753421 gmail com> wrote:
> run on win32. I would caution against overuse of g_idle_add though.
> Recently I've been saving off the data from the thread and then doing
> the GUI updates at the start of the next expose/draw.

I generally do both. I like:

* a background thread finishes some task and calls g_idle_add_full()
with high priority to send the result to the main thread
* the main thread runs the idle callback and uses the data to update
the program model
* the program model queues a view refresh for every part of the model
that changes with a low priority g_idle_add_full()
* the views update from the model and (eventually) turn into an expose/draw

The idea is to decouple model updates from drawing, so under load your
program just updates the display less frequently, it never drops data
or lags.

Different structures will suit different programs, of course.


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