Multitasking question: Making a picture viewer, loading lots of images in the background
realhet
real_het at hotmail.com
Wed Apr 3 12:02:21 UTC 2019
On Wednesday, 3 April 2019 at 04:09:45 UTC, DanielG wrote:
> My understanding is that there's no benefit to creating more
> than the number of hyperthreads your CPU
Yes.
I'm just searching for a higher abstraction to manage this easily
in D. I've already did it years ago on Delphi. (-> Manage N
worker threads, and only put light stress on the thread which is
running on the same core as the main thread.) Later it was easier
to make it in OpenMP, and now I'm just looking for an even
prettier way in DLang.
Also it's good to know what happens inside. I've checked Resource
Monitor, and as you said, the thread count reached above 1000 in
the first 3 seconds of running the program.
But after that something unusual happens: While my overall CPU
usage was still high, the number of threads dropped down to 15,
and the remaining 20 seconds of processing was don like this.
But still, while all the processing, the main thread got no cpu%
at all, it was able to render only the very first frame, the one
that displayed the empty 'loading in progress' images. After 23
sec I was able to see all the 1000 pictures.
>You should probably be looking at std.parallelism (TaskPool etc)
>for this.
Thank you for mentioning, this
std.parallelism.Task.executeOnNewThread will be the next test. Is
that behaving the same way like 'spawn'? From its name, I don't
think so, but I'll find out.
More information about the Digitalmars-d-learn
mailing list