Threadsafe project model

Esben Mose Hansen kde at mosehansen.dk
Fri Jul 16 07:34:36 UTC 2010


On Friday 16 July 2010 01:52:03 Andreas Pakulat wrote:
> Then the model would still be thread-unsafe and can be declared as such
> and still be somewhat usable from a background thread (as far as
> notifying the gui of changes is concerned).

How about simply queueing the additions? Do the background thread really need 
the added items to work? Then the GUI thread could pick up the additions when 
it got around to it,  the model signals wouldn't give us problems, and the 
background parser wouldn't be blocked by the GUI thread.

the signature could be something like 

void add_new_item(id, parent_id, data1,, data2, data3);

where the id is a suitable id that can be calculated from the background 
threads. If all else fails, you could always use thread-id + running number, 
or even a unique id.

Of course, the background thread could not read from those items, but that 
would be a bad idea in any case since the GUI thread could be removing those 
items again for some reason.

-- 
kind regards, Esben




More information about the KDevelop-devel mailing list