You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.5 KiB
61 lines
1.5 KiB
#![allow(dead_code)]
|
|
|
|
|
|
#[macro_export] macro_rules! unwrap {
|
|
(return $($code:expr)?; $err:expr) => {
|
|
{
|
|
match $err {
|
|
Ok(v) => v,
|
|
Err(e) => {
|
|
eprintln!("Error: {}", e);
|
|
|
|
#[allow(unused_variables)]
|
|
let rc = -1;
|
|
$(let rc = $code;)?
|
|
|
|
std::process::exit(rc)
|
|
},
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
mod state;
|
|
mod pool;
|
|
mod map;
|
|
mod job;
|
|
mod work;
|
|
mod arg;
|
|
mod open;
|
|
|
|
mod consts;
|
|
|
|
fn work(arg::Operation{output, inputs}: arg::Operation) -> Result<(), Box<dyn std::error::Error>>
|
|
{
|
|
// todo:
|
|
// - create and open output file
|
|
let output = open::output(output)?;
|
|
// - open and stat all input files in order (`job::create_from_file`).
|
|
// - `fallocate` the output file fd to the sum of all input file sizes
|
|
|
|
// - `mmap` the output file as writable
|
|
//
|
|
// - spawn the task thread pool
|
|
// - move the output mapped file to the thread-safe refcounted `state::State`.
|
|
// - dispatch jobs to the pool with their fds, stats, and calculated output offsets; along with a reference to the output mapped file and a sender for the completion stream (`job::Prelude::start`)
|
|
|
|
// - Read the completion stream receiver until all file jobs have been signaled as completed
|
|
// - wait on all worker threads to complete.
|
|
// - ensure all data was written.
|
|
|
|
Ok(())
|
|
}
|
|
|
|
fn main() {
|
|
match arg::parse_args() {
|
|
Ok(op) => unwrap!(return 1; work(op)),
|
|
Err(arg::ArgParseError::NoOutput) => arg::usage(),
|
|
}
|
|
|
|
}
|