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

Minor download cleanup #233

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions walkers/src/tiles.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use egui::{pos2, Color32, Context, Mesh, Rect, Vec2};
use egui::{ColorImage, TextureHandle};
use futures::channel::mpsc::{channel, Receiver, Sender};
use image::ImageError;
use lru::LruCache;

Expand Down Expand Up @@ -76,10 +77,10 @@ pub struct HttpTiles {
cache: LruCache<TileId, Option<Texture>>,

/// Tiles to be downloaded by the IO thread.
request_tx: futures::channel::mpsc::Sender<TileId>,
request_tx: Sender<TileId>,

/// Tiles that got downloaded and should be put in the cache.
tile_rx: futures::channel::mpsc::Receiver<(TileId, Texture)>,
tile_rx: Receiver<(TileId, Texture)>,

#[allow(dead_code)] // Significant Drop
runtime: Runtime,
Expand All @@ -106,8 +107,8 @@ impl HttpTiles {
// Minimum value which didn't cause any stalls while testing.
let channel_size = 20;

let (request_tx, request_rx) = futures::channel::mpsc::channel(channel_size);
let (tile_tx, tile_rx) = futures::channel::mpsc::channel(channel_size);
let (request_tx, request_rx) = channel(channel_size);
let (tile_tx, tile_rx) = channel(channel_size);
let attribution = source.attribution();
let tile_size = source.tile_size();
let max_zoom = source.max_zoom();
Expand All @@ -120,12 +121,13 @@ impl HttpTiles {
egui_ctx,
));

// Just arbitrary value which seemed right.
#[allow(clippy::unwrap_used)]
let cap = std::num::NonZeroUsize::new(256).unwrap();
let cache_size = std::num::NonZeroUsize::new(256).unwrap();

Self {
attribution,
cache: LruCache::new(cap), // Just arbitrary value which seemed right.
cache: LruCache::new(cache_size),
request_tx,
tile_rx,
runtime,
Expand Down
Loading