pub fn hardware_threads() -> Result<usize, ()> {
    let path = "/sys/devices/system/cpu/present";
    let f = File::open(path).map_err(|e| error!("failed to open file ({:?}): {}", path, e))?;
    let mut f = BufReader::new(f);

    let mut line = String::new();
    f.read_line(&mut line)
        .map_err(|_| error!("failed to read line"))?;
    let line = line.trim();
    let a: Vec<&str> = line.split('-').collect();
    a.last()
        .unwrap_or(&"0")
        .parse::<usize>()
        .map_err(|e| error!("could not parse num cpus from file ({:?}): {}", path, e))
        .map(|i| i + 1)
}
/// helper function to discover the number of hardware threads
helper function to discover the number of hardware threads
helper function to discover the number of hardware threads
pub fn hardware_threads() -> Result<usize, ()> {
    let path = "/sys/devices/system/cpu/present";
    let f = File::open(path).map_err(|e| error!("failed to open file ({:?}): {}", path, e))?;
    let mut f = BufReader::new(f);
    let mut line = String::new();
    f.read_line(&mut line)
        .map_err(|_| error!("failed to read line"))?;
    let line = line.trim();
    let a: Vec<&str> = line.split('-').collect();
    a.last()
        .unwrap_or(&"0")
        .parse::<usize>()
        .map_err(|e| error!("could not parse num cpus from file ({:?}): {}", path, e))
        .map(|i| i + 1)
}
pub fn hardware_threads ( ) -> Result < usize , ( ) > { let path = " " ; let f = File :: open ( path ) . map_err ( | e | error ! ( " " path e ) ) ? ; let mut f = BufReader :: new ( f ) ; let mut line = String :: new ( ) ; f . read_line ( & mut line ) . map_err ( | _ | error ! ( " " ) ) ? ; let line = line . trim ( ) ; let a : Vec < & str > = line . split ( '-' ) . collect ( ) ; a . last ( ) . unwrap_or ( & " " ) . parse :: < usize > ( ) . map_err ( | e | error ! ( " " path e ) ) . map ( | i | i + 1 ) }
helper function to discover the number of hardware threads
helper function to discover the number of hardware threads