Introduce xbps_array_foreach_cb() and use it in random code.

This routine will spawn a thread per core to process N items stored
in the specified array, the last thread gets the remainder of items left.

Results have shown that xbps benefits if there is a considerable amount
of items and number of threads being spawned.

Use it in xbps_pkgdb_foreach_cb(), xbps-pkgdb(8), xbps-query(8)
and xbps-rindex(8).

On UP systems there's no overhead because pthread(3) is not used at all.

WIP! investigate if it can be used in libxbps (xbps_rpool_foreach()),
and finish conversion of xbps-rindex(8) -c.
This commit is contained in:
Juan RP
2013-07-27 09:47:16 +02:00
parent 432067de48
commit 0c7701f2bc
9 changed files with 255 additions and 295 deletions

View File

@@ -59,8 +59,8 @@ int repo_ownedby(struct xbps_handle *, int, char **);
/* From list.c */
unsigned int find_longest_pkgver(struct xbps_handle *, xbps_object_t);
int list_pkgs_in_dict(struct xbps_handle *, xbps_object_t, void *, bool *);
int list_manual_pkgs(struct xbps_handle *, xbps_object_t, void *, bool *);
int list_pkgs_in_dict(struct xbps_handle *, xbps_object_t, const char *, void *, bool *);
int list_manual_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *);
int list_orphans(struct xbps_handle *);
int list_pkgs_pkgdb(struct xbps_handle *);