#![allow(missing_docs)]
use std::sync::{Arc, Barrier};
use std::thread;
use std::time::Duration;
use wireshift_core::backend::{Backend, BackendSubmission};
use wireshift_core::config::RingConfig;
use wireshift_core::op::OpDescriptor;
use wireshift_uring::UringBackend;
#[test]
fn test_concurrent_100_threads() {
let config = RingConfig::default().with_queue_depth(256);
let (tx, rx) = std::sync::mpsc::channel();
let backend = Arc::new(UringBackend::new(&config, tx).unwrap());
let thread_count = 100;
let ops_per_thread = 50;
let barrier = Arc::new(Barrier::new(thread_count));
let mut handles = vec![];
for t_id in 0..thread_count {
let backend_clone = Arc::clone(&backend);
let barrier_clone = Arc::clone(&barrier);
handles.push(thread::spawn(move || {
barrier_clone.wait();
for i in 0..ops_per_thread {
let id = (t_id as u64 * 1000) + i as u64;
let submission = BackendSubmission { timeout: None,
id,
descriptor: OpDescriptor::Nop,
};
let _ = backend_clone.submit(submission);
}
}));
}
for handle in handles {
handle.join().unwrap();
}
}