pub(crate) fn allocate(stack: ProcStack, future: F, schedule: S) -> NonNull<()> {
        // Compute the layout of the proc for allocation. Abort if the computation fails.
        let proc_layout = Self::proc_layout();

        unsafe {
            // Allocate enough space for the entire proc.
            let raw_proc = match NonNull::new(alloc::alloc(proc_layout.layout) as *mut ()) {
                None => std::process::abort(),
                Some(p) => p,
            };

            let raw = Self::from_ptr(raw_proc.as_ptr());

            // Write the pdata as the first field of the proc.
            (raw.pdata as *mut ProcData).write(ProcData {
                state: AtomicUsize::new(SCHEDULED | HANDLE | REFERENCE),
                awaiter: Cell::new(None),
                vtable: &ProcVTable {
                    raw_waker: RawWakerVTable::new(
                        Self::clone_waker,
                        Self::wake,
                        Self::wake_by_ref,
                        Self::decrement,
                    ),
                    schedule: Self::schedule,
                    drop_future: Self::drop_future,
                    get_output: Self::get_output,
                    decrement: Self::decrement,
                    destroy: Self::destroy,
                    run: Self::run,
                },
            });

            // Write the stack as the second field of the proc.
            (raw.stack as *mut ProcStack).write(stack);

            // Write the schedule function as the third field of the proc.
            (raw.schedule as *mut S).write(schedule);

            // Write the future as the fourth field of the proc.
            raw.future.write(future);

            raw_proc
        }
    }
/// Allocates a proc with the given `future` and `schedule` function.
///
/// It is assumed there are initially only the `LightProc` reference and the `ProcHandle`.
Allocates a proc with the given `future` and `schedule` function.
It is assumed there are initially only the `LightProc` reference and the `ProcHandle`.
Allocates a proc with the given ` future ` and ` schedule ` function . It is assumed there are initially only the ` LightProc ` reference and the ` ProcHandle ` .
pub(crate) fn allocate(stack: ProcStack, future: F, schedule: S) -> NonNull<()> {
        // Compute the layout of the proc for allocation. Abort if the computation fails.
        let proc_layout = Self::proc_layout();
        unsafe {
            // Allocate enough space for the entire proc.
            let raw_proc = match NonNull::new(alloc::alloc(proc_layout.layout) as *mut ()) {
                None => std::process::abort(),
                Some(p) => p,
            };
            let raw = Self::from_ptr(raw_proc.as_ptr());
            // Write the pdata as the first field of the proc.
            (raw.pdata as *mut ProcData).write(ProcData {
                state: AtomicUsize::new(SCHEDULED | HANDLE | REFERENCE),
                awaiter: Cell::new(None),
                vtable: &ProcVTable {
                    raw_waker: RawWakerVTable::new(
                        Self::clone_waker,
                        Self::wake,
                        Self::wake_by_ref,
                        Self::decrement,
                    ),
                    schedule: Self::schedule,
                    drop_future: Self::drop_future,
                    get_output: Self::get_output,
                    decrement: Self::decrement,
                    destroy: Self::destroy,
                    run: Self::run,
                },
            });
            // Write the stack as the second field of the proc.
            (raw.stack as *mut ProcStack).write(stack);
            // Write the schedule function as the third field of the proc.
            (raw.schedule as *mut S).write(schedule);
            // Write the future as the fourth field of the proc.
            raw.future.write(future);
            raw_proc
        }
    }
pub ( crate ) fn allocate ( stack : ProcStack , future : F , schedule : S ) -> NonNull < ( ) > { // Compute the layout of the proc for allocation. Abort if the computation fails. let proc_layout = Self :: proc_layout ( ) ; unsafe { // Allocate enough space for the entire proc. let raw_proc = match NonNull :: new ( alloc :: alloc ( proc_layout . layout ) as * mut ( ) ) { None => std :: process :: abort ( ) , Some ( p ) => p , } ; let raw = Self :: from_ptr ( raw_proc . as_ptr ( ) ) ; // Write the pdata as the first field of the proc. ( raw . pdata as * mut ProcData ) . write ( ProcData { state : AtomicUsize :: new ( SCHEDULED | HANDLE | REFERENCE ) , awaiter : Cell :: new ( None ) , vtable : & ProcVTable { raw_waker : RawWakerVTable :: new ( Self :: clone_waker , Self :: wake , Self :: wake_by_ref , Self :: decrement , ) , schedule : Self :: schedule , drop_future : Self :: drop_future , get_output : Self :: get_output , decrement : Self :: decrement , destroy : Self :: destroy , run : Self :: run , } , } ) ; // Write the stack as the second field of the proc. ( raw . stack as * mut ProcStack ) . write ( stack ) ; // Write the schedule function as the third field of the proc. ( raw . schedule as * mut S ) . write ( schedule ) ; // Write the future as the fourth field of the proc. raw . future . write ( future ) ; raw_proc } }
Allocates a proc with the given `future` and `schedule` function.
Allocates a proc with the given ` future ` and ` schedule ` function .
stack
ProcStack
future
F
schedule
S
stack
ProcStack
future
F
schedule
S