Skip to main content

spawn_document

Function spawn_document 

Source
pub fn spawn_document(
    buffer_id: BufferId,
    document: Document,
    registry: CommandRegistryHandle,
) -> RopeDocumentHandle
Expand description

Spawn a fresh document actor on the shared runtime and return the handle. Calling this is the only way to obtain a RopeDocumentHandle. Document moves into the actor; once spawned the document is reachable only through the handle.

registry is shared by the ArcSwap handle so the actor can run grammar dispatches without coupling to the App’s lifetime and see runtime plugin registrations on its next dispatch (PL8.B / B3b). Cloning the handle Arc is one atomic increment.

The actor task survives until every clone of the returned handle is dropped; on the last drop the mailbox closes, the actor’s recv loop exits, and the task returns.