patch_seq_strand_spawn

Function patch_seq_strand_spawn 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn patch_seq_strand_spawn( entry: extern "C" fn(Stack) -> Stack, initial_stack: Stack, ) -> i64
Expand description

Spawn a strand (coroutine) with initial stack

§Safety

  • entry must be a valid function pointer that can safely execute on any thread
  • initial_stack must be either null or a valid pointer to a StackValue that:
    • Was heap-allocated (e.g., via Box)
    • Has a ’static lifetime or lives longer than the coroutine
    • Is safe to access from the spawned thread
  • The caller transfers ownership of initial_stack to the coroutine
  • Returns a unique strand ID (positive integer)

§Memory Management

The spawned coroutine takes ownership of initial_stack and will automatically free the final stack returned by entry upon completion.