MINOR: task: introduce work lists

Sometimes we need to delegate some list processing to a function running
on another thread. In this case the list element will simply be queued
into a dedicated self-locked list and the task responsible for this list
will be woken up, calling the associated function which will run over the
list.

This is what work_list does. Such lists will be dedicated to a limited
type of work but will significantly ease such remote handling. A function
is provided to create these per-thread lists, their tasks and to properly
bind each task to a distinct thread, so that the caller only has to store
the resulting pointer to the start of the structure.

These structures should not be abused though as each head will consume
4 pointers per thread, hence 32 bytes per thread or 2 kB for 64 threads.

(cherry picked from commit 64e6012eb92691bb9dd8d5cbfda0494d22c33b50)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/include/proto/task.h b/include/proto/task.h
index 424e8ba..4044bd4 100644
--- a/include/proto/task.h
+++ b/include/proto/task.h
@@ -541,6 +541,19 @@
 	        !LIST_ISEMPTY(&task_per_thread[tid].task_list));
 }
 
+/* adds list item <item> to work list <work> and wake up the associated task */
+static inline void work_list_add(struct work_list *work, struct list *item)
+{
+	LIST_ADDQ_LOCKED(&work->head, item);
+	task_wakeup(work->task, TASK_WOKEN_OTHER);
+}
+
+struct work_list *work_list_create(int nbthread,
+                                   struct task *(*fct)(struct task *, void *, unsigned short),
+                                   void *arg);
+
+void work_list_destroy(struct work_list *work, int nbthread);
+
 /*
  * This does 3 things :
  *   - wake up all expired tasks