Hi
I'm trying to create a multithreaded library that calculate mandelbrot sets
i would like the api to look something like this:
1 2
|
MandelBrotGenerator genr;
std:future<MandelBrotData> fMandelData = genr.GenerateBrot(1.34f, 2.34f);
|
That way the user can choose whether to
get()
the value right away or wait for it.
Currently the way the
GenerateBrot
function works is by creating a threadpool of 8 threads and adding tasks to it for each pixel in the set,
and in the end it joins all the threads (which blocks the main thread - this is what i would like to change).
I cant figure out how to change the function to return a
std::future
and not block the main thread (since it depends on 8 threads not just 1),
so i was just wondering if maybe somebody could give me a quick psudo code example of how i could go about structuring something like that?
i've been trying to think about solutions on my own but i cant think of any
i'm fairly new to multithreaded programming so maybe it has an obvious anwser, sorry.