pub struct OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor> { /* private fields */ }Expand description
An adapter that wraps a static executor and erases its notifier type.
OwnedSomeStaticExecutorErasingNotifier takes ownership of an underlying
static executor and implements SomeStaticExecutor with a type-erased
notifier (Box<dyn ExecutorNotified>). This allows different executor
types to be used interchangeably through the DynStaticExecutor type.
§Type Parameters
UnderlyingExecutor- The concrete static executor type being wrapped
§When to Use
Use this adapter when you need to:
- Store executors with different notifier types in the same collection
- Pass executors through a uniform interface that accepts
DynStaticExecutor - Erase the executor’s notifier type while maintaining ownership
§Examples
§Creating and using an erased executor
use some_executor::static_support::OwnedSomeStaticExecutorErasingNotifier;
use some_executor::{SomeStaticExecutor, DynStaticExecutor};
use some_executor::task::{Task, Configuration};
// With a concrete executor implementation:
// let executor = MyExecutor::new();
// let mut erased = OwnedSomeStaticExecutorErasingNotifier::new(executor);
//
// // Spawn tasks as usual
// let task = Task::without_notifications(
// "example".to_string(),
// Configuration::default(),
// async { 42 }
// );
// let observer = erased.spawn_static(task);§Converting to a boxed dynamic executor
use some_executor::static_support::OwnedSomeStaticExecutorErasingNotifier;
use some_executor::{SomeStaticExecutor, DynStaticExecutor};
// With a concrete executor:
// let executor = MyExecutor::new();
// let erased = OwnedSomeStaticExecutorErasingNotifier::new(executor);
//
// // Get a boxed version for storage or passing around
// let boxed: Box<DynStaticExecutor> = erased.clone_box();§Implementation Notes
The adapter delegates all executor methods to the underlying executor,
with the exception of executor_notifier() which wraps the underlying
notifier in a Box<dyn ExecutorNotified>.
Implementations§
Source§impl<UnderlyingExecutor> OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>
impl<UnderlyingExecutor> OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>
Sourcepub fn new(executor: UnderlyingExecutor) -> Self
pub fn new(executor: UnderlyingExecutor) -> Self
Creates a new adapter wrapping the provided executor.
§Arguments
executor- The static executor to wrap
§Examples
use some_executor::static_support::OwnedSomeStaticExecutorErasingNotifier;
// With a concrete executor:
// let executor = MyExecutor::new();
// let erased = OwnedSomeStaticExecutorErasingNotifier::new(executor);Trait Implementations§
Source§impl<UnderlyingExecutor: Debug> Debug for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>
impl<UnderlyingExecutor: Debug> Debug for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>
Source§impl<UnderlyingExecutor: SomeStaticExecutor> SomeStaticExecutor for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>
impl<UnderlyingExecutor: SomeStaticExecutor> SomeStaticExecutor for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>
type ExecutorNotifier = Box<dyn ExecutorNotified>
Source§fn spawn_static<F, Notifier: ObserverNotified<F::Output>>(
&mut self,
task: Task<F, Notifier>,
) -> impl Observer<Value = F::Output>
fn spawn_static<F, Notifier: ObserverNotified<F::Output>>( &mut self, task: Task<F, Notifier>, ) -> impl Observer<Value = F::Output>
Spawns a static, non-Send future onto the runtime. Read more
Source§fn spawn_static_async<F, Notifier: ObserverNotified<F::Output>>(
&mut self,
task: Task<F, Notifier>,
) -> impl Future<Output = impl Observer<Value = F::Output>>
fn spawn_static_async<F, Notifier: ObserverNotified<F::Output>>( &mut self, task: Task<F, Notifier>, ) -> impl Future<Output = impl Observer<Value = F::Output>>
Spawns a static, non-Send future onto the runtime. Read more
Source§fn spawn_static_objsafe(
&mut self,
task: ObjSafeStaticTask,
) -> BoxedStaticObserver
fn spawn_static_objsafe( &mut self, task: ObjSafeStaticTask, ) -> BoxedStaticObserver
Spawns a static, non-Send future onto the runtime. Read more
Source§fn spawn_static_objsafe_async<'s>(
&'s mut self,
task: ObjSafeStaticTask,
) -> BoxedStaticObserverFuture<'s>
fn spawn_static_objsafe_async<'s>( &'s mut self, task: ObjSafeStaticTask, ) -> BoxedStaticObserverFuture<'s>
Spawns a static, non-Send future onto the runtime. Read more
Source§fn executor_notifier(&mut self) -> Option<Self::ExecutorNotifier>
fn executor_notifier(&mut self) -> Option<Self::ExecutorNotifier>
Produces an executor notifier.
Auto Trait Implementations§
impl<UnderlyingExecutor> Freeze for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>where
UnderlyingExecutor: Freeze,
impl<UnderlyingExecutor> RefUnwindSafe for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>where
UnderlyingExecutor: RefUnwindSafe,
impl<UnderlyingExecutor> Send for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>where
UnderlyingExecutor: Send,
impl<UnderlyingExecutor> Sync for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>where
UnderlyingExecutor: Sync,
impl<UnderlyingExecutor> Unpin for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>where
UnderlyingExecutor: Unpin,
impl<UnderlyingExecutor> UnwindSafe for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>where
UnderlyingExecutor: UnwindSafe,
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
Mutably borrows from an owned value. Read more