fix: limit concurrent thumbnail generation (#1138)
This commit is contained in:
parent
e3c793a44d
commit
a4e3bf3eea
3 changed files with 8 additions and 0 deletions
|
|
@ -95,6 +95,11 @@ const MAX_SEARCH_RESULTS: usize = 200;
|
|||
//TODO: configurable thumbnail size?
|
||||
const THUMBNAIL_SIZE: u32 = (ICON_SIZE_GRID as u32) * (ICON_SCALE_MAX as u32);
|
||||
|
||||
pub static THUMB_SEMAPHORE: LazyLock<tokio::sync::Semaphore> = LazyLock::new(|| {
|
||||
tokio::sync::Semaphore::const_new(num_cpus::get())
|
||||
});
|
||||
|
||||
|
||||
pub(crate) static SORT_OPTION_FALLBACK: LazyLock<HashMap<String, (HeadingOptions, bool)>> =
|
||||
LazyLock::new(|| {
|
||||
HashMap::from_iter(dirs::download_dir().into_iter().map(|dir| {
|
||||
|
|
@ -5634,6 +5639,7 @@ impl Tab {
|
|||
let message = {
|
||||
let path = path.clone();
|
||||
|
||||
_ = THUMB_SEMAPHORE.acquire().await;
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let start = Instant::now();
|
||||
let thumbnail = ItemThumbnail::new(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue