Struct hirofa_utils::task_manager::TaskManager
source · pub struct TaskManager { /* private fields */ }
Implementations§
source§impl TaskManager
impl TaskManager
pub fn new(thread_count: usize) -> Self
pub fn add_task<T: FnOnce() + Send + 'static>(&self, task: T)
sourcepub fn add_task_async<R: Send + 'static, T: Future<Output = R> + Send + 'static>(
&self,
task: T,
) -> impl Future<Output = Result<R, JoinError>>
pub fn add_task_async<R: Send + 'static, T: Future<Output = R> + Send + 'static>( &self, task: T, ) -> impl Future<Output = Result<R, JoinError>>
start an async task
§Example
use hirofa_utils::task_manager::TaskManager;
let tm = TaskManager::new(2);
let task = async {
println!("foo");
};
tm.add_task_async(task);
pub fn run_task_blocking<R: Send + 'static, T: FnOnce() -> R + Send + 'static>( &self, task: T, ) -> R
Auto Trait Implementations§
impl !Freeze for TaskManager
impl RefUnwindSafe for TaskManager
impl Send for TaskManager
impl Sync for TaskManager
impl Unpin for TaskManager
impl UnwindSafe for TaskManager
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