3 /* Copyright (c) 2007, 2009, 2010. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
12 #include "xbt/misc.h" /* SG_BEGIN_DECL */
13 #include "xbt/function_types.h"
14 #include "xbt/dynar.h"
18 /** @addtogroup XBT_parmap
19 * @brief Parallel map.
21 * A function is applied to the n first elements of a dynar in parallel,
22 * where n is the number of threads. The threads are persistent until the
23 * destruction of the parmap object.
25 * If there are more than n elements in the dynar, the worker threads should
26 * fetch themselves remaining work with xbt_parmap_next() and execute it.
30 /** \brief Queue data type (opaque type) */
32 typedef struct s_xbt_parmap *xbt_parmap_t;
34 XBT_PUBLIC(xbt_parmap_t) xbt_parmap_new(unsigned int num_workers);
35 XBT_PUBLIC(void) xbt_parmap_destroy(xbt_parmap_t parmap);
37 XBT_PUBLIC(void) xbt_parmap_apply(xbt_parmap_t parmap,
40 XBT_PUBLIC(void*) xbt_parmap_next(xbt_parmap_t parmap);
41 XBT_PUBLIC(unsigned long) xbt_parmap_get_worker_id(xbt_parmap_t parmap);