New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make image cache per-document rather than global #16048
Merged
+484
−640
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
72d7ee6
Make image cache per-document rather than global
ferjm 166c4e8
Move image cache implementation to the net crate
ferjm f4da165
Make ImageCacheImpl have a single Mutex<ImageCacheStore> and use Imag…
ferjm fa433a7
Remove useless ImageDecoderRunnable struct
ferjm File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
Remove useless ImageDecoderRunnable struct
- Loading branch information
commit fa433a74b1a36be08fd59c4c6295c2d4982159d4
| @@ -401,25 +401,6 @@ impl ImageCacheStore { | ||
| } | ||
| } | ||
|
|
||
| struct ImageDecoderRunnable { | ||
| store: Arc<Mutex<ImageCacheStore>>, | ||
| key: PendingImageId, | ||
| bytes: Arc<Vec<u8>>, | ||
| } | ||
|
|
||
| impl ImageDecoderRunnable { | ||
| fn run(&self) { | ||
| let local_store = self.store.clone(); | ||
| let bytes = self.bytes.clone(); | ||
| let key = self.key.clone(); | ||
| thread::spawn(move || { | ||
| let msg = decode_bytes_sync(key, &*bytes); | ||
| debug!("Image decoded"); | ||
| local_store.lock().unwrap().handle_decoder(msg); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| pub struct ImageCacheImpl { | ||
ferjm
Author
Member
|
||
| store: Arc<Mutex<ImageCacheStore>>, | ||
| } | ||
| @@ -545,12 +526,12 @@ impl ImageCache for ImageCacheImpl { | ||
| pending_load.bytes.mark_complete() | ||
| }; | ||
|
|
||
| let image_decoder_runnable = ImageDecoderRunnable { | ||
| store: self.store.clone(), | ||
| key: key, | ||
| bytes: bytes.clone(), | ||
| }; | ||
| image_decoder_runnable.run(); | ||
| let local_store = self.store.clone(); | ||
| thread::spawn(move || { | ||
| let msg = decode_bytes_sync(key, &*bytes); | ||
| debug!("Image decoded"); | ||
| local_store.lock().unwrap().handle_decoder(msg); | ||
| }); | ||
| } | ||
| Err(_) => { | ||
| debug!("Processing error for {:?}", key); | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
All the code using this now puts it in an extra Arc, right? Can we fix that by making this structure Clone and storing ImageCacheImpl (perhaps renaming it to ImageCacheHandle).