1 #ifndef CCAN_LBALANCE_H
2 #define CCAN_LBALANCE_H
11 * lbalance_new - initialize a load balancing structure.
13 struct lbalance *lbalance_new(void);
16 * lbalance_task_new - mark the starting of a new task.
17 * @lbalance: the load balancer from lbalance_new.
19 struct lbalance_task *lbalance_task_new(struct lbalance *lbalance);
22 * lbalance_task_free - mark the completion of a task.
23 * @task: the lbalance_task from lbalance_task_new, which will be freed.
24 * @usage: the resource usage for that task (or NULL).
26 * If @usage is NULL, you must have already wait()ed for the child so
27 * that lbalance_task_free() can derive it from the difference in
28 * getrusage() for the child processes.
30 * Otherwise, lbalance_task_free() is a noop, which is useful for failure
33 void lbalance_task_free(struct lbalance_task *task,
34 const struct rusage *usage);
37 * lbalance_target - how many tasks in parallel are recommended?
38 * @lbalance: the load balancer from lbalance_new.
40 * Normally you keep creating tasks until this limit is reached. It's
41 * updated by stats from lbalance_task_free.
43 unsigned lbalance_target(struct lbalance *lbalance);
46 * lbalance_free - free a load balancing structure.
47 * @lbalance: the load balancer from lbalance_new.
49 * Also frees any tasks still attached.
51 void lbalance_free(struct lbalance *lbalance);
52 #endif /* CCAN_LBALANCE_H */