usecrate::mach_sys::*; usecrate::AudioThreadPriorityError; use libc::{pthread_self, pthread_t}; use log::info; use mach::kern_return::{kern_return_t, KERN_SUCCESS}; use mach::mach_time::{mach_timebase_info, mach_timebase_info_data_t}; use mach::message::mach_msg_type_number_t; use mach::port::mach_port_t; use std::mem::size_of;
extern"C" { fn pthread_mach_thread_np(tid: pthread_t) -> mach_port_t; // Those functions are commented out in thread_policy.h but somehow it works just fine !? fn thread_policy_set(
thread: thread_t,
flavor: thread_policy_flavor_t,
policy_info: thread_policy_t,
count: mach_msg_type_number_t,
) -> kern_return_t; fn thread_policy_get(
thread: thread_t,
flavor: thread_policy_flavor_t,
policy_info: thread_policy_t,
count: &mut mach_msg_type_number_t,
get_default: &mut boolean_t,
) -> kern_return_t;
}
// can't use size_of in const fn just now in stable, use a macro for now.
macro_rules! THREAD_TIME_CONSTRAINT_POLICY_COUNT {
() => {
(size_of::<thread_time_constraint_policy_data_t>() / size_of::<integer_t>()) as u32
};
}
// Get current thread attributes, to revert back to the correct setting later if needed.
rt_priority_handle.tid = tid;
// false: we want to get the current value, not the default value. If this is `false` after // returning, it means there are no current settings because of other factor, and the // default was returned instead. letmut get_default: boolean_t = 0; letmut count: mach_msg_type_number_t = THREAD_TIME_CONSTRAINT_POLICY_COUNT!(); letmut rv: kern_return_t = thread_policy_get(
tid,
THREAD_TIME_CONSTRAINT_POLICY,
(&mut time_constraints) as *mut _ as thread_policy_t,
&mut count,
&mut get_default,
);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.