perf: use tokio
not sure how much this helps practically
This commit is contained in:
parent
d925059ef4
commit
da1e64d898
3 changed files with 21 additions and 5 deletions
|
|
@ -75,9 +75,13 @@ impl State {
|
|||
let size = 1000 / self.columns as u32;
|
||||
let (task, handle) = Task::perform(
|
||||
async move {
|
||||
utils::load_thumbnail(&path, size)
|
||||
.map(|img| (path, handle_from_image(img)))
|
||||
.map_err(Arc::new)
|
||||
tokio::task::spawn_blocking(move || {
|
||||
utils::load_thumbnail(&path, size)
|
||||
.map(|img| (path, handle_from_image(img)))
|
||||
.map_err(Arc::new)
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
},
|
||||
Message::ImageLoaded,
|
||||
)
|
||||
|
|
@ -194,7 +198,7 @@ impl State {
|
|||
|handle| widget::image(handle).into(),
|
||||
))
|
||||
.key(self.key)
|
||||
.anticipate(2000)
|
||||
.anticipate(500)
|
||||
.on_show(|_size| Message::LoadImage(path.clone()))
|
||||
.on_hide(Message::UnloadImage(path.clone())),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue