Skip to content
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
merged 4 commits into from Mar 27, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Remove useless ImageDecoderRunnable struct

  • Loading branch information
ferjm committed Mar 27, 2017
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 {

This comment has been minimized.

@jdm

jdm Mar 27, 2017

Member

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).

This comment has been minimized.

@ferjm

ferjm Mar 27, 2017

Author Member

@jdm if I am not wrong, this means that I need to use net::image_cache::ImageCacheHandle instead of net_traits::image_cache::ImageCache in all consumers, is this ok?

This comment has been minimized.

@jdm

jdm Mar 27, 2017

Member

Bleah, you're right. Let's leave it the way it is.

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.
You can’t perform that action at this time.