Show progress while loading reads the image sizes
Before decoding, loadImages reads every header to size the batch against the free memory. That pass was serial, silent and could not be cancelled, so the loading window sat at "0 of N". LoadProgress gains onSized, the headers are read in parallel on the same cursor-driven workers as the decodes, and a cancel stops the pass. The window's bar runs twice, "Checking sizes" then "Decoding", and the CLI prints a sizing line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+5
-2
@@ -61,9 +61,12 @@ struct LoadFailure {
|
||||
};
|
||||
|
||||
// Lets a caller follow a long batch decode and abort it. Both members are
|
||||
// touched from the decoding threads, so `onFile` must be thread-safe and must
|
||||
// not block: the GUI only bumps a counter from it and wakes the main thread.
|
||||
// touched from the decoding threads, so `onSized` and `onFile` must be
|
||||
// thread-safe and must not block: the GUI only bumps a counter from them and
|
||||
// wakes the main thread. `onSized` follows the first pass, which reads every
|
||||
// header to size the batch; `onFile` follows the decodes after it.
|
||||
struct LoadProgress {
|
||||
std::function<void(std::size_t done, std::size_t total, const std::string& path)> onSized;
|
||||
std::function<void(std::size_t done, std::size_t total, const std::string& path)> onFile;
|
||||
std::atomic<bool>* cancel = nullptr;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user