byteor_runtime/
platform.rs

1use crate::{MlockallPreset, PinningPreset, SchedPreset};
2
3/// Apply an `mlockall` preset to the current process.
4///
5/// If `preset` is `None`, this is a no-op.
6pub fn apply_mlockall_preset(preset: MlockallPreset) -> Result<(), String> {
7    byteor_ops::apply_mlockall(preset).map_err(|e| e.to_string())
8}
9
10/// Apply a scheduler preset to the current thread.
11pub fn apply_sched_preset(preset: SchedPreset) -> Result<(), String> {
12    byteor_ops::apply_sched(preset).map_err(|e| e.to_string())
13}
14
15/// Apply a pinning preset to the current thread.
16///
17/// `role_name` is used as a stable distribution key.
18pub fn apply_pinning_for_current_thread(
19    preset: PinningPreset,
20    role_name: &str,
21) -> Result<(), String> {
22    byteor_ops::apply_pinning_for_role(preset, role_name).map_err(|e| e.to_string())
23}
24
25/// Pin the current thread to a specific CPU.
26pub fn pin_current_thread_to_cpu(cpu: usize) -> Result<(), String> {
27    byteor_ops::pin_current_thread_to_cpu(cpu).map_err(|e| e.to_string())
28}