pin_current_generator

Function pin_current_generator 

Source
pub fn pin_current_generator() -> bool
Expand description

Request that the current generator be pinned to the current task.

This MUST be called from within a task that is executing inside a Worker’s generator. When called, it signals the Worker to transfer ownership of the current generator to the task, allowing the task to have its own stackful coroutine execution context.

§Returns

true if the pin request was successfully registered, false if not in a task context.

§Example

use maniac_runtime::runtime::worker::pin_current_generator;

// Inside an async task running on a worker:
async {
    // Request to pin the current generator
    if pin_current_generator() {
        // Generator will be pinned after this returns
        // Task will continue execution with its own generator
    }
}