mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-09 23:27:17 +01:00
8ae698d1dc
We have some duplication in handling queues, so this is an attempt at deduplicating some of that work. `daemon_conn` now uses the `msg_queue` and `channeld` was also migrated to `msg_queue`. At the same time I made `msg_queue` create a copy of the messages or takes over messages marked with `take()`. This should make cleaning up messages easier.
23 lines
560 B
C
23 lines
560 B
C
/* Helper for simple message queues. */
|
|
#ifndef LIGHTNING_LIGHTNINGD_MSG_QUEUE_H
|
|
#define LIGHTNING_LIGHTNINGD_MSG_QUEUE_H
|
|
#include "config.h"
|
|
#include <ccan/io/io.h>
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
struct msg_queue {
|
|
const u8 **q;
|
|
const tal_t *ctx;
|
|
};
|
|
|
|
void msg_queue_init(struct msg_queue *q, const tal_t *ctx);
|
|
|
|
void msg_enqueue(struct msg_queue *q, const u8 *add);
|
|
|
|
const u8 *msg_dequeue(struct msg_queue *q);
|
|
|
|
#define msg_queue_wait(conn, q, next, arg) \
|
|
io_out_wait((conn), (q), (next), (arg))
|
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_MSG_QUEUE_H */
|