Finn1552 wrote:How to programmatically determine in C or C++ whether a specified path is on a flash (SSD) drive or a magnetic hard drive? I'm only interested in fixed drives, not removable ones, although it will be nice to determine the type of a removable drive as well.
I can see ways to get the root volume path for a specified end path, and a way to pdfescapethe GUID of this volume, but I'm not finding a way to query this volume's hardware traits.
Given what the OP has said in their answer to my comment, I don't think this is the right question.
Instead, what actually matters here is the seek time and perhaps the latency of the disk containing the images to be loaded (see comment above).
An SSD, of course, has no seek time or latency to speak of, so it pays to decode several images in parallel (in separate threads) to make best use of the CPU. But the OP tells us that doing this causes a decrease in performance with a conventional hard disk, probably because the disk heads are jumping around all over the place trying to keep all the decoding threads fed with data.
So, can you have the best of both worlds? Can you make best use of the CPU without rattling the disk? Well, I think so, yes. What I would do is to have a single thread that reads images into memory, one at a time, to keep the disk happy.
But this thread should just read 'raw' image data. Any further processing should be hived off to some number of 'worker' threads (the exact number should probably be limited to the number of logical processors the machine has) so that it can be done in parallel. Then it should all run lickety-split on any kind of disk.
And that's all I'm going to say. OP, you have a bit of queuing / scheduling architecture to design but it'll be worth it.
If you only ever want to run this on Windows, check out the ThreadPool, or consider using std::async (which, contrary to the C++ standard, is built on top of the thread pool and offers nice C++ pass-by-value semantics).
Otherwise, take a look at the C++ Thread support library.
Edit: That's obviously a fair bit of work for the OP, see the comments, So, short-term suggestion, find some way of rattling the disk and measure the elapsed time to decide whether to load images in parallel or to process them one-at-a-time.
Just loading a few images in parallel should do it. During development, measure that on both an HDD and an SSD and then you will be able to determine a (hard-coded) value you can use as your threshold.
Note: Open the files with FILE_FLAG_NO_BUFFERING when doing this, else the disk cache will probably lie to you.