multiSnow / mcomix3

End of Fork
Other
97 stars 39 forks source link

Stop pdf extraction when program terminates #155

Closed salty-horse closed 3 years ago

salty-horse commented 3 years ago

PDF pages can take several seconds to extract. If I attempt to terminate mcomix while extraction is taking place, I have to wait for all the current queued page extractions to complete. This makes the program seem unresposive, and my OS even suggests to force-terminate it.

This patch uses a similar approach as #110, passing a program termination checker into the PDF archive class, and checks it periodically while the PDF extraction process is running. I pass it after the archive is created, so it doesn't interfere with any constructor signatures of existing archive subclasses who don't use the termination check.

It also makes already-queued individual page extractions check the status before the start and do nothing. Maybe that part isn't required.

Two questions:

multiSnow commented 3 years ago

https://github.com/multiSnow/mcomix3/commit/2e2835909633d9e974ca7bf7fe360c2265f00e0a should fix this issue. Please test if it works as expected.

salty-horse commented 3 years ago

It doesn't quite fix it. If I terminate the program while the first page is being rendered, it skips rendering the first page, but still renders the second and third page, and only quitting after 4 seconds.

multiSnow commented 3 years ago

It doesn't quite fix it. If I terminate the program while the first page is being rendered, it skips rendering the first page, but still renders the second and third page, and only quitting after 4 seconds.

It is caused by another issue. It should be fixed by https://github.com/multiSnow/mcomix3/commit/4e5607301b630f38d20e39ccb455cc0235bd4dfd. Please test if it works as expected, in both single-thread and multi-thread extracting.

salty-horse commented 3 years ago

Works great, thanks!

I tested with "maximum number of thumbnail threads" of 1 and 3, and "maximum number of concurrent extraction threads" of 1 and 2.