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§
Source§impl ExecutionScope
impl ExecutionScope
Sourcepub fn new() -> ExecutionScope
pub fn new() -> ExecutionScope
Constructs an execution scope. Use ExecutionScope::build()
if you want to specify
parameters.
Sourcepub 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.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Returns the active count: the number of tasks that are active and will prevent shutdown.
Sourcepub fn spawn(
&self,
task: impl Future<Output = ()> + Send + 'static,
) -> JoinHandle<()>
pub fn spawn( &self, task: impl Future<Output = ()> + Send + 'static, ) -> JoinHandle<()>
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 shutdown(&self)
Sourcepub fn force_shutdown(&self)
pub fn force_shutdown(&self)
Forcibly shut down the executor without respecting the active guards.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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§
Source§impl Clone for ExecutionScope
impl Clone for ExecutionScope
Source§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 moreSource§impl Debug for ExecutionScope
impl Debug for ExecutionScope
Source§impl PartialEq for ExecutionScope
impl PartialEq for ExecutionScope
impl Eq for ExecutionScope
Auto Trait Implementations§
impl Freeze for ExecutionScope
impl !RefUnwindSafe for ExecutionScope
impl Send for ExecutionScope
impl Sync for ExecutionScope
impl Unpin for ExecutionScope
impl !UnwindSafe for ExecutionScope
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)