Skip to main content

Module context_task

Module context_task 

Source
Expand description

TC.2 — the per-plugin actor bridge for sticky-context providers.

The context analogue of decoration_task.rs: a dedicated async task owns the plugin’s Store<PluginState> for life (the Store is !Sync), a [ContextCall] crosses an mpsc channel with a oneshot reply, and the Send + Sync ContextClient serializes calls onto the single-consumer loop. PluginHost::spawn_context_source instantiates the context-plugin world under the plugin’s grant and returns (ContextClient, ContextActor); the caller drives ContextActor::run on its multi-thread runtime (the lib owns no runtime).

The tree crosses as a call-scoped borrow. Unlike the other async seams, context-scopes takes option<borrow<tree-snapshot>>. The actor pushes an owned TreeSnapshotResource into the store’s table, lends a non-owning borrow to the guest, and reclaims the owned entry after the call — the grammar_trampoline pattern (TS.1), which is what keeps the tree-sitter capability meaning “the tree you were handed” rather than “any buffer’s tree, any time”. The owned entry lives across the guest’s suspension; the host owns it throughout, and any node the guest derives is guest-owned and dropped before it returns.

Re-exports§

pub use crate::lattice::plugin_host::types::ContextRequest;
pub use crate::lattice::plugin_host::types::ContextScope;

Structs§

ContextActor
The per-plugin actor: owns the Store + context bindings for the plugin’s life and serves calls off the channel until every ContextClient drops.
ContextClient
The Send + Sync handle a caller holds. Cloning is cheap (an mpsc Sender clone); every clone talks to the same actor / Store, so calls serialize on the single-consumer loop the !Sync Store needs.