Hiya guys.

Im working of a proof-of-contept project at the moment, and it seems to me that multiple threads would be advantageous.

Im looking into having the game spawn a couple of worker threads to better time-manage some of the
more time-intensive terrain handling stuff, maybe more will be added later.

Specifically(at this time):
ONE: Loading a chunk of data (using WinAPI's) from a large file on HDD and inserting it into a selected memory locations.
TWO: Taking data from an array filled by thread ONE, adjust the heightmap of a 128x128(max) terrain slab.

These threads operate independantly, and adjust a flag-system stored within the data-chunk they are manipulating.

ie: The first byte of the memory-area filled by thread ONE is a status flag, showing when 'busy' and when 'complete'.
And thread TWO sets a flag of the entity to on WHILE it is processing.

So I am being careful (so far) that the threads never CREATE or REMOVE any objects, and the objects that the data is in
can see if its 'busy' and pause its removal (either the data or itself) until the processes are complete.


So now you know what Im tring to achieve, here comes the "ask".
Im not asking for it to be written FOR me, I feel that defeats my purpose.
I just need some functional code, showing how to get a single (or even multiple if tricky) worker-thread up and running,
and how to safely manage him/them. (including terminations/sleeping/etc later on)
And hints and tips ion threads in general. ... And someone to ask questions of when it all goes horribly wrong.


Thaks guys...




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial