ExecutorDrain

Struct ExecutorDrain 

Source
pub struct ExecutorDrain { /* private fields */ }
Expand description

A future that completes when all tasks in an executor have finished.

ExecutorDrain is returned by Executor::drain_async() and implements Future<Output = ()>. It polls the executor’s internal state to determine when all tasks have completed execution.

§Examples

use some_global_executor::Executor;
use some_executor::SomeExecutor;
use some_executor::task::{Task, Configuration};

let mut executor = Executor::new("async-drain".to_string(), 2);

// Spawn some work
let task = Task::without_notifications(
    "work".to_string(),
    Configuration::default(),
    async {
        // Simulate some work
        42
    }
);
executor.spawn(task);

// In async context, you would use:
// executor.drain_async().await;
// Here we use synchronous drain for the example
executor.drain();

Trait Implementations§

Source§

impl AsMut<Executor> for ExecutorDrain

Provides mutable access to the underlying Executor from an ExecutorDrain.

This allows operations like resizing the thread pool even while draining.

§Examples

use some_global_executor::{Executor, ExecutorDrain};

let executor = Executor::new("test".to_string(), 2);
let mut drain = executor.drain_async();
drain.as_mut().resize(4);  // Resize while draining
Source§

fn as_mut(&mut self) -> &mut Executor

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<Executor> for ExecutorDrain

Provides immutable access to the underlying Executor from an ExecutorDrain.

§Examples

use some_global_executor::{Executor, ExecutorDrain};

let executor = Executor::new("test".to_string(), 2);
let drain = executor.drain_async();
let name = drain.as_ref().name();
assert_eq!(name, "test");
Source§

fn as_ref(&self) -> &Executor

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for ExecutorDrain

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Executor> for ExecutorDrain

Converts an Executor into an ExecutorDrain future.

This conversion is equivalent to calling Executor::drain_async().

§Examples

use some_global_executor::{Executor, ExecutorDrain};

let executor = Executor::new("test".to_string(), 2);
let drain: ExecutorDrain = executor.into();
// In async context: drain.await;
// For this example, convert back and drain:
let executor: Executor = drain.into();
executor.drain();
Source§

fn from(executor: Executor) -> Self

Converts to this type from the input type.
Source§

impl From<ExecutorDrain> for Executor

Converts an ExecutorDrain back to its underlying Executor.

This is useful when you need to access the executor after initiating a drain operation but before it completes.

§Examples

use some_global_executor::{Executor, ExecutorDrain};

let executor = Executor::new("test".to_string(), 2);
let drain: ExecutorDrain = executor.into();
let executor: Executor = drain.into();
executor.drain();
Source§

fn from(drain: ExecutorDrain) -> Self

Converts to this type from the input type.
Source§

impl Future for ExecutorDrain

Source§

type Output = ()

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.