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