use log::trace; use std::time::Duration; use std::thread; use rand::Rng; use rotonda_store::prelude::*; use rotonda_store::prelude::multi::*; use rotonda_store::meta_examples::PrefixAs; fn main() -> Result<(), Box> { #[cfg(feature = "cli")] env_logger::init(); trace!("Starting multi-threaded yolo testing...."); let tree_bitmap = MultiThreadedStore::::new()?; // let f = Arc::new(std::sync::atomic::AtomicBool::new(false)); let mut pfx_int = 0_u32; // let threads = // (0..16).enumerate().map(|(i, _)| { // let tree_bitmap = tree_bitmap.clone(); // let start_flag = Arc::clone(&f); let thread = std::thread::Builder::new() .name(1_u8.to_string()) .spawn(move || -> Result<(), Box> { // while !start_flag.load(std::sync::atomic::Ordering::Acquire) { let mut rng= rand::thread_rng(); println!("park thread {}", 1); thread::park(); // } print!("\nstart {} ---", 1); // let mut x = 0; while pfx_int <= 24 { pfx_int += 1; let pfx = Prefix::new_relaxed( pfx_int.into_ipaddr(), 32, ); // x += 1; // print!("{}-", i); let asn: u32 = rng.gen(); match tree_bitmap.insert( &pfx.unwrap(), Record::new(0, 0, RouteStatus::Active, PrefixAs(asn)), None ) { Ok(_) => {} Err(e) => { println!("{}", e); } }; } Ok(()) // println!("--thread {} done.", 1); }) .unwrap(); // }); // thread::sleep(Duration::from_secs(60)); // f.store(true, std::sync::atomic::Ordering::Release); // thread.for_each(|t| { thread.thread().unpark(); // }); thread::sleep(Duration::from_secs(10)); println!("------ end of inserts\n"); // let guard = unsafe { epoch::unprotected() }; // let s_spfx = tree_bitmap.match_prefix( // &pfx.unwrap(), // &MatchOptions { // match_type: rotonda_store::MatchType::ExactMatch, // include_all_records: true, // include_less_specifics: true, // include_more_specifics: true, // }, // guard, // ); // println!("query result"); // println!("{}", s_spfx); // println!("{}", s_spfx.more_specifics.unwrap()); println!("-----------"); Ok(()) }