Skip to content

Commit

Permalink
Merge pull request #233 from podusowski/minor-download-cleanup
Browse files Browse the repository at this point in the history
Minor download cleanup
  • Loading branch information
podusowski authored Nov 20, 2024
2 parents 3833f36 + 62a0988 commit 4d0ca81
Showing 1 changed file with 8 additions and 6 deletions.
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

0 comments on commit 4d0ca81

Please sign in to comment.