pub struct CommandRunner<T: ICommandInfo> { /* private fields */ }Expand description
Queue and execute commands across a pool of workers.
Implementations§
Source§impl<T: ICommandInfo + 'static> CommandRunner<T>
impl<T: ICommandInfo + 'static> CommandRunner<T>
Sourcepub fn new(
mediator: Arc<CommandMediator<T>>,
registry: Arc<CommandRegistry<T>>,
workers: Arc<WorkerPool<T>>,
) -> Self
pub fn new( mediator: Arc<CommandMediator<T>>, registry: Arc<CommandRegistry<T>>, workers: Arc<WorkerPool<T>>, ) -> Self
Create a new CommandRunner.
Sourcepub async fn start(&self, worker_count: usize)
pub async fn start(&self, worker_count: usize)
Start any number of workers.
Each worker will have a unique ID.
Status will be set to Running.
Sourcepub async fn queue_request<R: Executable + Into<T::Request> + Send + Sync + 'static>(
&self,
request: R,
) -> Result<(), Report<QueueError>>
pub async fn queue_request<R: Executable + Into<T::Request> + Send + Sync + 'static>( &self, request: R, ) -> Result<(), Report<QueueError>>
Queue a command as a request.
Sourcepub async fn get_commands(
&self,
) -> MutexGuard<'_, HashMap<T::Request, CommandStatus<T>>>
pub async fn get_commands( &self, ) -> MutexGuard<'_, HashMap<T::Request, CommandStatus<T>>>
Lock and return the current command status map.
The MutexGuard must be dropped promptly or Worker execution will block.
Trait Implementations§
Source§impl<T: ICommandInfo + 'static> FromServicesAsync for CommandRunner<T>
impl<T: ICommandInfo + 'static> FromServicesAsync for CommandRunner<T>
Source§type Error = ResolveError
type Error = ResolveError
Error type returned by
FromServicesAsync::from_services_async.Source§async fn from_services_async(
services: &ServiceProvider,
) -> Result<Self, Report<Self::Error>>
async fn from_services_async( services: &ServiceProvider, ) -> Result<Self, Report<Self::Error>>
Create an instance asynchronously by resolving dependencies from the
ServiceProvider.Auto Trait Implementations§
impl<T> Freeze for CommandRunner<T>
impl<T> !RefUnwindSafe for CommandRunner<T>
impl<T> Send for CommandRunner<T>
impl<T> Sync for CommandRunner<T>
impl<T> Unpin for CommandRunner<T>
impl<T> UnsafeUnpin for CommandRunner<T>
impl<T> !UnwindSafe for CommandRunner<T>
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