-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoriginal_style.rs
More file actions
40 lines (34 loc) · 1.02 KB
/
Copy pathoriginal_style.rs
File metadata and controls
40 lines (34 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#[cfg(not(target_os = "linux"))]
fn main() {
eprintln!("original_style is only supported on Linux");
std::process::exit(1);
}
#[cfg(target_os = "linux")]
fn main() -> tailslayer::Result<()> {
use std::sync::{
Arc,
atomic::{AtomicUsize, Ordering},
};
use tailslayer::{HugePageSize, LinuxHardwareSpec, LinuxHedgedReader};
// Adjust these host-specific settings to match your machine.
let hardware = LinuxHardwareSpec {
hugepage_size: HugePageSize::Size2MiB,
..LinuxHardwareSpec::new([11, 12])
};
let mut reader = LinuxHedgedReader::<u8>::builder()
.linux_hardware_spec(&hardware)
.capacity(16)
.build()?;
reader.insert(0x43)?;
reader.insert(0x44)?;
let signal_index = Arc::new(AtomicUsize::new(1));
let wait_signal = Arc::clone(&signal_index);
reader.start_workers(
move || wait_signal.load(Ordering::Relaxed),
|value| {
println!("value={value:#x}");
},
)?;
reader.join()?;
Ok(())
}