Merged new cli options into this branch. Re-added pre-release & `io_uring` feature flag.

Fortune for genmarkov's current commit: Half curse − 半凶
io-uring-async-support
Avril 2 weeks ago
parent 5293810b79
commit 216aa7abd1
Signed by: flanchan
GPG Key ID: 284488987C31F630

2
Cargo.lock generated

@ -388,7 +388,7 @@ checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
[[package]]
name = "markov"
version = "0.2.2"
version = "0.2.2+1"
dependencies = [
"async-compression",
"bytes",

@ -1,6 +1,6 @@
[package]
name = "markov"
version = "0.2.2"
version = "0.2.2+1"
description = "Generate string of text from Markov chain fed by stdin or file(s)"
authors = ["Avril <flanchan@cumallover.me>"]
edition = "2018"
@ -20,10 +20,10 @@ lto = "fat"
strip = false
[features]
default = ["threads"]
default = ["threads", "io_uring"]
threads = ["zstd/zstdmt", "dep:num_cpus"]
#io_uring = ["dep:tokio-uring", "dep:async-compression", "dep:futures", "dep:tokio"]
io_uring = ["dep:tokio-uring", "dep:async-compression", "dep:futures", "dep:tokio"]
[dependencies]
async-compression = { version = "0.4.18", features = ["tokio", "zstd", "zstdmt"], optional = true }

@ -376,6 +376,29 @@ where S: io::Write + ?Sized
stream.flush()
}
#[cfg(feature="io_uring")]
#[deprecated = "Runs through compression *twice* (one on the sync side, even) see below. Must be re-written to properly use `io_uring::*`"]
pub fn save_chain_to_file(output_file: std::fs::File, chain: &Chain<String>, compress: bool) -> io::Result<()>
{
compile_error!("TODO: Make `save_to_chain() that takes callback for write stream to create compression stream & write to it, since io_uring backing takes care of that, but we want the uncompressed metadata writing to be the same.");
// let output_file = fs::OpenOptions::new()
// .create_new(! force)
// .create(true)
// .truncate(force)
// .write(true)
// .open(path);
let (mut stream, bg) = io_uring::create_write_compressed(output_file)?;
todo!("^^^ Ehh... No, this isn't right... `stream` is the *encoder* stream, we still need to do the metadata thing done in `_sync`()... XXX: Can we factor that out to something that will take a callback maybe??? Idk... im tired...");
save_chain_to_sync(&mut stream, chain, compress)?;
stream.flush()?;
drop(stream); // NOTE: Drop the sending side so the recv side can know there is no more data. **MUST** be done before the `.join()`.
bg.join().expect("Fatal error in background I/O thread")?;
Ok(())
}
#[cfg(feature="io_uring")]
mod io_uring {
use super::*;

Loading…
Cancel
Save