getnamo / 7zip-cpp

Fork of SevenZip++ for modern builds.
Other
224 stars 94 forks source link

Add support for aborting a zip operation. #22

Closed error454 closed 6 years ago

error454 commented 6 years ago

ProgressCallback.h

Changed to use pure virtual functions to eliminate a compile error on the UE4 library side.

ArchiveExtractCallback / ArchiveUpdateCallback

Implementation of CheckBreak(). The primary means of allowing zip operations to break is to return CheckBreak() in the vast majority of interface callbacks that an archive gets over its lifetime. As to which callbacks should return CheckBreak() vs not, this was mostly copied from the SevenZip sample code. I did omit the check from GetProperty because it seemed a little overkill and I was also mildly (perhaps without reason) worried about hitting the mutex on the FThreadSafeBool too frequently since GetProperty seemed high on the most frequently called list.

Since this is COM, returning E_ABORT in any of these callbacks effectively terminates the operation. CheckBreak() is simply an easy entry point that in-turn calls through to the ProgressCallback virtual method OnCheckBreak() which is overriden in the UE4 library implementation using an FThreadSafeBool.

getnamo commented 6 years ago

This looks good, have you tested that it behaves as expected?

error454 commented 6 years ago

This looks good, have you tested that it behaves as expected?

Yes, I've been testing over the last 2 days. It works perfectly and memory usage looks perfect.

getnamo commented 6 years ago

Awesome, what I estimate as maximum of ~100-1000ish core cache misses (mutex) per zip should also be ok and not a concern in my mind.

Merged.

getnamo commented 6 years ago

forgot to actually merge it... 🥇