Skip to content

Commit

Permalink
Merge pull request #39 from rfdzan/patches
Browse files Browse the repository at this point in the history
fix: collapsed impl and renamed variable
  • Loading branch information
rfdzan authored Apr 20, 2024
2 parents 178625d + 99d0c3f commit 822b09f
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions src/bulk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@ pub struct ParallelBuilder {
device_num: u8,
}
impl ParallelBuilder {
/// Builds a new [`Parallel`] with default or specified configuration.
/// # Example
/// This is the minimal requirements for using this method:
/// ```
/// # fn main() {
/// # use jippigy::Parallel;
/// let mut vector_of_bytes: Vec<Vec<u8>> = Vec::new();
/// let _build = Parallel::from_vec(vector_of_bytes).build();
/// # }
/// ```
pub fn build(self) -> Parallel {
let (tx, rx) = channel::unbounded();
Parallel {
main_worker: Worker::new_fifo(),
vec: self.vec,
to_thread: StuffThatNeedsToBeSent {
device_num: self.device_num,
quality: self.quality,
stealers: Vec::with_capacity(usize::from(self.device_num)),
},
transmitter: tx,
receiver: rx,
}
}
/// Specifies the quality of compressed images.
/// Defaults to 95 (95% of the original quality).
///
Expand Down Expand Up @@ -40,32 +64,6 @@ impl ParallelBuilder {
}
}
}
impl ParallelBuilder {
/// Builds a new [`Parallel`] with default or specified configuration.
/// # Example
/// This is the minimal requirements for using this method:
/// ```
/// # fn main() {
/// # use jippigy::Parallel;
/// let mut vector_of_bytes: Vec<Vec<u8>> = Vec::new();
/// let _build = Parallel::from_vec(vector_of_bytes).build();
/// # }
/// ```
pub fn build(self) -> Parallel {
let (tx, rx) = channel::unbounded();
Parallel {
main_worker: Worker::new_fifo(),
vec: self.vec,
to_thread: StuffThatNeedsToBeSent {
device_num: self.device_num,
quality: self.quality,
stealers: Vec::with_capacity(usize::from(self.device_num)),
},
transmitter: tx,
receiver: rx,
}
}
}
#[derive(Debug)]
pub struct StuffThatNeedsToBeSent {
device_num: u8,
Expand All @@ -92,10 +90,10 @@ impl StuffThatNeedsToBeSent {
continue;
};
for stealer in stealer_guard.iter() {
let Steal::Success(direntry) = stealer.steal() else {
let Steal::Success(jpeg_bytes) = stealer.steal() else {
continue;
};
payload.push(direntry);
payload.push(jpeg_bytes);
break;
}
let _checks = stealer_guard
Expand Down

0 comments on commit 822b09f

Please sign in to comment.