- flexible number of threads
- path: &str -> path: AsRef<Path>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tiffwrite"
|
||||
version = "2025.3.1"
|
||||
version = "2025.5.0"
|
||||
edition = "2021"
|
||||
authors = ["Wim Pomp <w.pomp@nki.nl>"]
|
||||
license = "MIT"
|
||||
@@ -16,9 +16,9 @@ name = "tiffwrite"
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.97"
|
||||
chrono = "0.4.40"
|
||||
flate2 = "1.1.0"
|
||||
anyhow = "1.0.98"
|
||||
chrono = "0.4.41"
|
||||
flate2 = "1.1.1"
|
||||
ndarray = "0.16.1"
|
||||
num = "0.4.3"
|
||||
rayon = "1.10.0"
|
||||
|
||||
10
src/lib.rs
10
src/lib.rs
@@ -11,11 +11,12 @@ use std::collections::HashSet;
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::hash::{DefaultHasher, Hash, Hasher};
|
||||
use std::io::{Read, Seek, SeekFrom, Write};
|
||||
use std::path::Path;
|
||||
use std::time::Duration;
|
||||
use std::{cmp::Ordering, collections::HashMap};
|
||||
use std::{
|
||||
thread,
|
||||
thread::{sleep, JoinHandle},
|
||||
thread::{available_parallelism, sleep, JoinHandle},
|
||||
};
|
||||
use zstd::zstd_safe::CompressionLevel;
|
||||
use zstd::{stream::Encoder, DEFAULT_COMPRESSION_LEVEL};
|
||||
@@ -672,9 +673,9 @@ impl Drop for IJTiffFile {
|
||||
}
|
||||
|
||||
impl IJTiffFile {
|
||||
/// create new tifffile from path string, use it's save() method to save frames
|
||||
/// create new tifffile from path, use it's save() method to save frames
|
||||
/// the file is finalized when it goes out of scope
|
||||
pub fn new(path: &str) -> Result<Self> {
|
||||
pub fn new<P: AsRef<Path>>(path: P) -> Result<Self> {
|
||||
let mut file = OpenOptions::new()
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
@@ -806,9 +807,10 @@ impl IJTiffFile {
|
||||
A: AsArray<'a, T, Ix2>,
|
||||
T: Bytes + Clone + Send + Sync + 'static,
|
||||
{
|
||||
let n_threads = usize::from(available_parallelism()?);
|
||||
loop {
|
||||
self.collect_threads(false)?;
|
||||
if self.threads.len() < 48 {
|
||||
if self.threads.len() < n_threads {
|
||||
break;
|
||||
}
|
||||
sleep(Duration::from_millis(100));
|
||||
|
||||
Reference in New Issue
Block a user