pub fn spawn_remote(
cx: &Cx,
node: NodeId,
computation: ComputationName,
input: RemoteInput,
) -> Result<RemoteHandle, RemoteError>Expand description
Spawns a named computation on a remote node.
This is the primary entry point for distributed structured concurrency. The caller specifies:
- A target
NodeIdidentifying where to run the computation - A
ComputationNameidentifying what to run (no closure shipping) - A
RemoteInputcontaining serialized arguments
The function requires a RemoteCap from the Cx, ensuring that
remote operations are impossible without explicit capability.
§Region Ownership
The returned RemoteHandle is conceptually owned by the region of
the calling task. When the region closes, it waits for all remote
handles to resolve (or escalates per policy).
§Current Contract
Attached runtimes can use deterministic harnesses such as
DistributedHarness or later
real transports that implement the protocol defined in this module. When no
runtime is attached, spawn_remote() resolves the handle to the configured
explicit fallback error immediately. This keeps behavior deterministic and
avoids detached wall-clock work outside structured concurrency.
§Errors
Returns RemoteError::NoCapability if the context does not have
a RemoteCap.
§Example
use asupersync::remote::{spawn_remote, NodeId, ComputationName, RemoteInput};
let mut handle = spawn_remote(
&cx,
NodeId::new("worker-1"),
ComputationName::new("encode_block"),
RemoteInput::new(serialized_data),
)?;
let result = handle.join(&cx).await?;
if let RemoteOutcome::Success(data) = result {
// process data
}