Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmr,main: add tmrl_count #694

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/re_tmr.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ int tmr_status(struct re_printf *pf, void *unused);
void tmr_init(struct tmr *tmr);
void tmr_start_dbg(struct tmr *tmr, uint64_t delay, tmr_h *th, void *arg,
const char *file, int line);
uint32_t tmrl_count(struct tmrl *tmrl);


/**
* @def tmr_start(tmr, delay, th, arg)
Expand Down
2 changes: 1 addition & 1 deletion src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ int re_debug(struct re_printf *pf, void *unused)
err |= re_hprintf(pf, " polling: %d\n",
re_atomic_rlx(&re->polling));
err |= re_hprintf(pf, " sig: %d\n", re->sig);
err |= re_hprintf(pf, " timers: %u\n", list_count(&re->tmrl));
err |= re_hprintf(pf, " timers: %u\n", tmrl_count(re->tmrl));
err |= re_hprintf(pf, " mutex: %p\n", re->mutex);
err |= re_hprintf(pf, " tid: %p\n", re->tid);
err |= re_hprintf(pf, " thread_enter: %d\n",
Expand Down
22 changes: 22 additions & 0 deletions src/tmr/tmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,25 @@ uint64_t tmr_get_expire(const struct tmr *tmr)

return (tmr->jfs > jfs) ? (tmr->jfs - jfs) : 0;
}


/**
* Get current timer list count
*
* @param tmrl Timer list object
*
* @return timer list count
*/
uint32_t tmrl_count(struct tmrl *tmrl)
{
uint32_t c;

if (!tmrl)
return 0;

mtx_lock(tmrl->lock);
c = list_count(&tmrl->list);
mtx_unlock(tmrl->lock);

return c;
}