Compare commits
3 Commits
cuddle-ple
...
main
Author | SHA1 | Date | |
---|---|---|---|
119fb101cf | |||
177820f3c3 | |||
3fc9c3143f |
@@ -5,6 +5,12 @@ Manage concurrent tasks with optional limits, cancellation, and first-error prop
|
|||||||
|
|
||||||
Inpired by golang (errgroups)
|
Inpired by golang (errgroups)
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
The library is still new, and as such the API is subject to change, I don't expect changes to the add and wait functions, but the rest may change. I might also move to custom error types, and or removing the tokio_utils entirely to slim down the package. It shouldn't affect the user too much however.
|
||||||
|
|
||||||
|
The crate is in production, and has seen extensive use
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Unlimited or bounded concurrency** via `with_limit(usize)`.
|
- **Unlimited or bounded concurrency** via `with_limit(usize)`.
|
||||||
@@ -104,6 +110,6 @@ See [LICENSE-MIT](LICENSE-MIT) and [LICENSE-APACHE](LICENSE-APACHE) for details.
|
|||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
Simply create an issue here or pr https://github.com/kjuulh/noworkers.git, development happens publicly at: git.front.kjuulh.io/kjuulh/noworkers.
|
Simply create an issue here or pr https://github.com/kjuulh/noworkers.git, development happens publicly at: https://git.front.kjuulh.io/kjuulh/noworkers.
|
||||||
|
|
||||||
|
|
||||||
|
@@ -3,6 +3,24 @@ use std::{future::Future, sync::Arc};
|
|||||||
use tokio::{sync::Mutex, task::JoinHandle};
|
use tokio::{sync::Mutex, task::JoinHandle};
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
|
|
||||||
|
pub mod extensions {
|
||||||
|
use crate::Workers;
|
||||||
|
|
||||||
|
pub trait WithSysLimitCpus {
|
||||||
|
fn with_limit_to_system_cpus(&mut self) -> &mut Self;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WithSysLimitCpus for Workers {
|
||||||
|
fn with_limit_to_system_cpus(&mut self) -> &mut Self {
|
||||||
|
self.with_limit(
|
||||||
|
std::thread::available_parallelism()
|
||||||
|
.expect("to be able to get system cpu info")
|
||||||
|
.into(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type ErrChan = Arc<
|
type ErrChan = Arc<
|
||||||
Mutex<(
|
Mutex<(
|
||||||
Option<tokio::sync::oneshot::Sender<anyhow::Error>>,
|
Option<tokio::sync::oneshot::Sender<anyhow::Error>>,
|
||||||
|
Reference in New Issue
Block a user