Hi
i am working on a program which has a really time expensive part. To start quicker i thought to swap this part out in a thread. For the time expensive part there are a lot of calculations of variables of a list. If done for a list element a "done" flag would be set for that element. That is to have only working data in the main part of the program which waits for this "done". For the start of the program i need only the first element calculated, which goes in a usable time. My problem is that list selection is done outside of the calculation thread and inside which gives collisions of the calculated data. I thought to stop main working for the element calculation part in the calculation thread, but didn't find any commands for that in PureBasic. The mutex part is read from mine, but if i want to use that, i have to put the main part of the program also in a thread - that i don't want to do.
How would you solve this problem? Do you have some ideas for me? Or a pointer if i see something wrong? Thanks for your answer.
Sigi
collisions using threads for a list data calculation
Re: collisions using threads for a list data calculation
I'd use a Map - perhaps something like this:
Code: Select all
Procedure loopingThread(run)
While run
element=doElementCalculations()
mapKey$=createMapKey(element)
If elementMap(mapKey$)<>#doneFlag
elementMap(mapKey$)=#doneFlag
processElement(element)
EndIf
Wend
EndProcedure
there is no sig, only zuul (and the following disclaimer)
WARNING: may be talking out of his hat
WARNING: may be talking out of his hat