Struct package_directory::ExecutionScope
pub struct ExecutionScope { /* private fields */ }
Expand description
An execution scope that is hosting tasks for a group of connections. See the module level documentation for details.
Actual execution will be delegated to an “upstream” executor - something that implements
[futures::task::Spawn
]. In a sense, this is somewhat of an analog of a multithreaded capable
[futures::stream::FuturesUnordered
], but this some additional functionality specific to the
vfs library.
Use ExecutionScope::new()
or ExecutionScope::build()
to construct new
ExecutionScope
es.
Implementations§
§impl ExecutionScope
impl ExecutionScope
pub fn new() -> ExecutionScope
pub fn new() -> ExecutionScope
Constructs an execution scope that has no entry_constructor
. Use
ExecutionScope::build()
if you want to specify other parameters.
pub fn build() -> ExecutionScopeParams
pub fn build() -> ExecutionScopeParams
Constructs a new execution scope builder, wrapping the specified executor and optionally
accepting additional parameters. Run [ExecutionScopeParams::new()
] to get an actual
ExecutionScope
object.
pub fn spawn(&self, task: impl Future<Output = ()> + Send + 'static)
pub fn spawn(&self, task: impl Future<Output = ()> + Send + 'static)
Sends a task
to be executed in this execution scope. This is very similar to
[futures::task::Spawn::spawn_obj()
] with a minor difference that self
reference is not
exclusive.
If the task needs to prevent itself from being shutdown, then it should use the
try_active_guard
function below.
For the “vfs” library it is more convenient that this method allows non-exclusive
access. And as the implementation is employing internal mutability there are no downsides.
This way ExecutionScope
can actually also implement [futures::task::Spawn
] - it just was
not necessary for now.
pub fn token_registry(&self) -> &TokenRegistry
pub fn entry_constructor( &self ) -> Option<Arc<dyn EntryConstructor + Sync + Send>>
pub fn shutdown(&self)
pub fn force_shutdown(&self)
pub fn force_shutdown(&self)
Forcibly shut down the executor without respecting the active guards.
pub fn resurrect(&self)
pub fn resurrect(&self)
Restores the executor so that it is no longer in the shut-down state. Any tasks that are still running will continue to run after calling this.
pub async fn wait(&self)
pub async fn wait(&self)
Wait for all tasks to complete.
pub fn try_active_guard(&self) -> Option<ActiveGuard>
pub fn try_active_guard(&self) -> Option<ActiveGuard>
Prevents the executor from shutting down whilst the guard is held. Returns None if the executor is shutting down.
pub fn active_guard(&self) -> ActiveGuard
pub fn active_guard(&self) -> ActiveGuard
As above, but succeeds even if the executor is shutting down. This can be used in drop implementations to spawn tasks that must run before the executor shuts down.
Trait Implementations§
§impl Clone for ExecutionScope
impl Clone for ExecutionScope
§fn clone(&self) -> ExecutionScope
fn clone(&self) -> ExecutionScope
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for ExecutionScope
impl Debug for ExecutionScope
§impl PartialEq for ExecutionScope
impl PartialEq for ExecutionScope
§fn eq(&self, other: &ExecutionScope) -> bool
fn eq(&self, other: &ExecutionScope) -> bool
self
and other
values to be equal, and is used
by ==
.