MINOR: connection: simplify subscription by adding a registration function
This new function wl_set_waitcb() prepopulates a wait_list with a tasklet
and a context and returns it so that it can be passed to ->subscribe() to
be added to a connection or conn_stream's wait_list. The caller doesn't
need to know all the insiders details anymore this way.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index a2580f1..8344c95 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -773,6 +773,15 @@
cs->data = data;
}
+static inline struct wait_list *wl_set_waitcb(struct wait_list *wl, struct task *(*cb)(struct task *, void *, unsigned short), void *ctx)
+{
+ if (!wl->task->process) {
+ wl->task->process = cb;
+ wl->task->context = ctx;
+ }
+ return wl;
+}
+
/* Installs the connection's mux layer for upper context <ctx>.
* Returns < 0 on error.
*/