From 088f292c1101adb15716705fd0e753de9668f9cf Mon Sep 17 00:00:00 2001
From: Daniel Schadt <kingdread@gmx.de>
Date: Tue, 17 Jan 2023 20:04:19 +0100
Subject: replace std::mpsc with crossbeam_channel

---
 src/renderer.rs | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

(limited to 'src')

diff --git a/src/renderer.rs b/src/renderer.rs
index de65da6..bb33ddc 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -1,4 +1,4 @@
-use std::{fs, mem, path::Path, sync::mpsc, thread};
+use std::{fs, path::Path, thread};
 
 use color_eyre::{
     eyre::{bail, Result},
@@ -147,7 +147,7 @@ pub fn lazy_colorization<P: AsRef<Path>, F: Fn(usize) + Send + Sync>(
     }
 
     type Job = (u64, u64, Vec<u8>);
-    let (tx, rx) = mpsc::sync_channel::<Job>(30);
+    let (tx, rx) = crossbeam_channel::bounded::<Job>(30);
 
     thread::scope(|s| {
         let saver = s.spawn(move || loop {
@@ -165,7 +165,7 @@ pub fn lazy_colorization<P: AsRef<Path>, F: Fn(usize) + Send + Sync>(
 
         layer
             .into_parallel_tiles()
-            .try_for_each(|(tile_x, tile_y, tile)| {
+            .try_for_each_with(tx, |tx, (tile_x, tile_y, tile)| {
                 let colorized = colorize_tile(&tile, max.into());
                 let data = layer::compress_png_as_bytes(&colorized)?;
                 tx.send((tile_x, tile_y, data))?;
@@ -173,7 +173,6 @@ pub fn lazy_colorization<P: AsRef<Path>, F: Fn(usize) + Send + Sync>(
                 Ok::<(), Report>(())
             })?;
 
-        mem::drop(tx);
         saver.join().unwrap()?;
         Ok::<_, Report>(())
     })?;
-- 
cgit v1.2.3