diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/nproc.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/core/nproc.h b/src/core/nproc.h index 4a175b9..87cab23 100644 --- a/src/core/nproc.h +++ b/src/core/nproc.h @@ -33,5 +33,22 @@ guint get_max_online_threads(void); +/** + * Calcul de tranches de travaux, avec prise en compte des cas particuliers. + */ +#define compute_run_size(qty, cpus) \ + ({ \ + if (qty == 0) \ + *(cpus) = 0; \ + else \ + { \ + *(cpus) = get_max_online_threads(); \ + if (qty < *(cpus)) \ + *(cpus) = qty; \ + } \ + *(cpus) > 0 ? qty / *(cpus) : 0; \ + }) + + #endif /* _CORE_NPROC_H */ |