use self::ios_macos::*;
use ::mach::mach_types::thread_t;
use ::mach::vm_types::integer_t;
use ::mach::kern_return::KERN_SUCCESS;
impl LogicalCores
{
const _IsSettingProcessAffinitySupported: bool = false;
const _IsSettingThreadAffinitySupported: bool = false;
#[inline(always)]
fn _set_process_affinity(&self, _process_identifier: ProcessIdentifier) -> io::Result<()>
{
Ok(())
}
#[inline(always)]
fn _set_thread_affinity(&self, _thread_identifier: ThreadIdentifier) -> io::Result<()>
{
Ok(())
}
#[inline(always)]
pub fn set_current_thread_affinity_hint(affinity_tag: usize) -> io::Result<()>
{
Self::set_thread_affinity_hint(Self::current_thread_identifier(), affinity_tag)
}
#[inline(always)]
pub fn set_thread_affinity_hint(thread_identifier: ThreadIdentifier, affinity_tag: usize) -> io::Result<()>
{
let mut info = thread_affinity_policy_data_t
{
affinity_tag: affinity_tag as integer_t,
};
let thread = unsafe { pthread_mach_thread_np(thread_identifier) };
match unsafe { thread_policy_set(thread as thread_t, THREAD_AFFINITY_POLICY, &mut info as *mut _ as thread_policy_t, THREAD_AFFINITY_POLICY_COUNT) }
{
KERN_SUCCESS => Ok(()),
_ => Err(io::Error::from(io::ErrorKind::Other)),
}
}
}