dope-sys 0.76.0

Typed operating-system call contracts
Documentation
pub mod common;

use std::{cell::Cell, num::NonZero, ptr::NonNull};

use common::thread::Completed;
use dope_sys::thread;

#[test]
fn destruction_joins() {
    let attrs = thread::raw::Attrs::with_stack(
        NonZero::new(thread::STACK_MIN).expect("native stack minimum"),
    )
    .expect("thread attributes");
    let mut done = Completed(Cell::new(false));
    // SAFETY: done stays at this address and only the worker accesses its
    // cell until the temporary handle is destroyed and joins below.
    unsafe { attrs.spawn(NonNull::from(&mut done)) }.expect("native worker");
    assert!(done.0.get());
}