#[unsafe(no_mangle)]pub unsafe extern "C-unwind" fn nova_rt_task_spawn(
future: *mut u8,
) -> i64Expand description
Queue a { poll_code, state } future as a new task and return its id.
"C-unwind": see PollFn’s doc comment for why every entry point in
this module shares that ABI rather than plain "C".
§Safety
future must point to a live FUTURE_SIZE-byte
{ poll_code, state } block, and:
poll_code(FUTURE_SLOT_POLL) must be a non-nullPollFnaddress (see [read_future] for why null is undefined behaviour here, not a later fault);state(FUTURE_SLOT_STATE) must point to a live, writable block of at least(STATE_SLOT_TEMPS + n_temps) * 8bytes, and never fewer thanSTATE_MIN_SIZE.STATE_SLOT_OUTPUTis read unconditionally on completion – including for a future whoseasync fnreturns unit and has no temps, where nothing in the poll function itself ever touches that slot. A tag-only 8-byte state object satisfies neither this contract nor the executor’s read, and would be read 8 bytes past its allocation;statemust be allocated scanned (gc::alloc(.., true), which is whatnova_rt_allocdoes): a heap-valued output written toSTATE_SLOT_OUTPUTis kept alive by tracing through the state object, so an unscanned state object would let it be collected (see [poll_one]).