diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2017-09-09 20:43:28 +0300 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2017-12-31 12:20:59 +0100 |
commit | 2286a36ace915864bce935f49374f12cb9384e5d (patch) | |
tree | 80413e58e3badca18066c940f897f833984c6f10 | |
parent | 262ae0f98f21e91ff21f2082892f75a778d077a5 (diff) |
procqueue: add human-readable name to osmo_gapk_pq
Since this change, every processing queue may optionally have
an associated human-readable name. If name is not required,
NULL should be passed to the osmo_gapk_pq_create().
-rw-r--r-- | include/osmocom/gapk/procqueue.h | 5 | ||||
-rw-r--r-- | src/app_osmo_gapk.c | 2 | ||||
-rw-r--r-- | src/procqueue.c | 9 |
3 files changed, 13 insertions, 3 deletions
diff --git a/include/osmocom/gapk/procqueue.h b/include/osmocom/gapk/procqueue.h index 9b049a5..dfd0db1 100644 --- a/include/osmocom/gapk/procqueue.h +++ b/include/osmocom/gapk/procqueue.h @@ -52,10 +52,13 @@ struct osmo_gapk_pq_item { struct osmo_gapk_pq { struct llist_head items; unsigned n_items; + + /*! \brief human-readable name */ + const char *name; }; /* Processing queue management */ -struct osmo_gapk_pq *osmo_gapk_pq_create(void); +struct osmo_gapk_pq *osmo_gapk_pq_create(const char *name); int osmo_gapk_pq_prepare(struct osmo_gapk_pq *pq); int osmo_gapk_pq_execute(struct osmo_gapk_pq *pq); void osmo_gapk_pq_destroy(struct osmo_gapk_pq *pq); diff --git a/src/app_osmo_gapk.c b/src/app_osmo_gapk.c index 2ce0a31..6543eef 100644 --- a/src/app_osmo_gapk.c +++ b/src/app_osmo_gapk.c @@ -734,7 +734,7 @@ int main(int argc, char *argv[]) return rv; /* Create processing queue */ - gs->pq = osmo_gapk_pq_create(); + gs->pq = osmo_gapk_pq_create("main"); if (!gs->pq) { rv = -ENOMEM; LOGP(DAPP, LOGL_ERROR, "Error creating processing queue\n"); diff --git a/src/procqueue.c b/src/procqueue.c index 3303cce..2c7b7fc 100644 --- a/src/procqueue.c +++ b/src/procqueue.c @@ -32,7 +32,7 @@ extern TALLOC_CTX *gapk_root_ctx; /* crate a new (empty) processing queue */ struct osmo_gapk_pq * -osmo_gapk_pq_create(void) +osmo_gapk_pq_create(const char *name) { struct osmo_gapk_pq *pq; @@ -41,6 +41,13 @@ osmo_gapk_pq_create(void) if (!pq) return NULL; + if (name != NULL) { + /* Rename talloc context */ + talloc_set_name(pq, "struct osmo_gapk_pq '%s'", name); + /* Set queue name */ + pq->name = name; + } + /* Init its list of items */ INIT_LLIST_HEAD(&pq->items); |