geekaurora / czhttpfile Goto Github PK
View Code? Open in Web Editor NEWGeneric HTTP file downloading framework - supports custom data decoder.
License: MIT License
Generic HTTP file downloading framework - supports custom data decoder.
License: MIT License
[DownloadState]
Should wait for completeSetCachedItemsDict
before completes downloading to ensure downloaded state correct, which repies on cachedItemsDict
.
Should only update visitedDate if itemKey already exists, otherwise it won't download as URL itemKey already exists in cachedItemDict.
diskCacheManager.getCachedFile(withUrl:)
debounceTaskScheduler?.schedule()
**CZDiskCacheManager.flushCachedItemsDictToDisk(_:)**
CZDiskCacheManager.setCachedItemsDictWithoutLock(cachedItemsDict:key:subkey:value:skipIfKeyNotExists:)
SimpleThreadLock.execute<τ_0_0>(_:)
CZDiskCacheManager.cachedItemsDictLockWrite<τ_0_0>(isAsync:closure:)
CZDiskCacheManager.setCachedItemsDictForNewURL(_:fileSize:)
CZDiskCacheManager.setCacheFile(withUrl:data:completeSetCachedItemsDict:completeSaveCachedFile:)
@TheadSafe
property wrapper: when write the underlying variable.@TheadSafe
property wrapper with SimpleThreadLock
.[FlakyTest] Assertion at CZDiskCacheManager.setCacheFile(withUrl:).
Failed to write file - file doesn’t exist."
ioQueue.async(flags: .barrier) :
ioQueue.async(flags: .barrier) { [weak self] in
guard let `self` = self else { return }
CZFileHelper.removeDirectory(path: self.cacheFolderHelper.cacheFolder, createDirectoryAfterDeletion: true)
}
CZGithubAppKit - CZWebImage Crash (Force quit 5 times: Data = empty)(First page)
Write to file wasn't atomic, and no ioQueue.async(flags: .barrier)
:
In CZDiskCacheManager.setCacheFile()
,
data.write(to: fileURL)
should be data.write(to: fileURL, options: [.atomic])
.
In CZDiskCacheManager.setCacheFile()
,
ioQueue.async(flags: .barrier)
: will cause performance issue as many image files are being written to disk when scrolling. (it was ioQueue.async(flags: .barrier), removed for performance reason) - #38CZHttpFileDownloader.downloadHttpFile() - completion
closure is called twice.
self.cache.setCacheFile(withUrl:)
completeSetCachedItemsDict
closure.Parent Ticket: #35
In CZDiskCacheManager.setCacheFile()
,
ioQueue.async(flags: .barrier)
: will cause performance issue as many image files are being written to disk when scrolling. (it was ioQueue.async(flags: .barrier), removed for performance reason)p.s. Files writing is discrete - mostly won't conflict.
data.write(to: fileURL, options: [.atomic])
: atomic - won't Crash.[Risky - OK]: if two threads are writing data to the same temporary file - won't damage but data isn't corrent?
The reason to abandon .barrier
flag: it blocks other operations if any writing is on going. (Files writing is discrete: mostly won't conflict)
[Won't Fix] It won't cause issues:
atomic: An option to write data to an auxiliary file first and then replace the original file with the auxiliary file when the write completes.
https://developer.apple.com/documentation/foundation/nsdata/writingoptions/1411764-atomic
ioQueue.async(flags: .barrier)
back: FPS test [Cleaner: same - .atomic write]writingFiles
Set: skip if file is being writtenCrash caused by thread safety - #37
Sub ticket: #38
Without flushCachedItemsDictToDisk(): 60 FPS
1. DebounceTaskScheduler - cachedItemsDict: merges the same tasks with gap
and only executes the last task.
2. Write file: remove .barrier - CZDiskCacheManager.ioQueue.async()
sync()
- block main thread when get cache..userInitiated
to .default
(Faster: image slower)A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.