pub struct Scope { /* private fields */ }Expand description
A set of children owned by one process.
See the module documentation for a description of a scope. A Scope is a handle. A clone of it costs
little, and any task can use it. A spawn through a Scope always succeeds. But, as with tokio::spawn, a
successful spawn does not guarantee that the child runs. If a child is spawned after its scope closed, the child is
dropped.
A handle does not hold the children that wait to start. The owner of the scope holds them, or the
UnadoptedScope before a worker adopts the scope. Thus, a child can hold a handle to its own scope without
keeping the scope alive.
Implementations§
Source§impl Scope
impl Scope
Sourcepub fn spawn<S, T>(&self, child: T) -> ChildId
pub fn spawn<S, T>(&self, child: T) -> ChildId
Spawns a child into the scope.
Accepts all values that SupervisorHandle::spawn accepts. This
includes a nested supervisor. By default, the child is hosted.
The returned ChildId identifies the child in this scope.
Sourcepub fn enter_sync<R>(&self, f: impl FnOnce() -> R) -> R
pub fn enter_sync<R>(&self, f: impl FnOnce() -> R) -> R
Runs f with this scope as the current one.
This is the synchronous version of enter.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scope
impl RefUnwindSafe for Scope
impl Send for Scope
impl Sync for Scope
impl Unpin for Scope
impl UnsafeUnpin for Scope
impl UnwindSafe for Scope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Track for T
impl<T> Track for T
§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
Tracked wrapper. Read more§fn in_current_resource_group(self) -> Tracked<Self>
fn in_current_resource_group(self) -> Tracked<Self>
Tracked wrapper. Read more