From 7173e9bd025094a1f74ad05879d1de5b9091a15c Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Fri, 1 Mar 2019 09:13:38 -0500 Subject: [PATCH] thread: add spdk_thread_has_pollers() This function add possibility to check if there are registered pollers on particular thread. Change-Id: I80af06a10c5c1b54fed5bb28a3aa769a52d8a206 Signed-off-by: Tomasz Zawadzki Reviewed-on: https://review.gerrithub.io/c/446624 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Darek Stojaczyk --- CHANGELOG.md | 5 +++++ include/spdk/thread.h | 10 ++++++++++ lib/thread/thread.c | 11 +++++++++++ 3 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b0fd5b24..c8a3aeae2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ spdk_nvme_probe_poll_async() were added to enable this feature. Added new strip_size_kb rpc param on create to replace the more ambiguous strip_size. The strip_size rpc param is deprecated. +### thread + +Added spdk_thread_has_pollers() function to verify if there are +any registered pollers to be run on the thread. + ## v19.01: ### ocf bdev diff --git a/include/spdk/thread.h b/include/spdk/thread.h index 724fa46eb..2b864df42 100644 --- a/include/spdk/thread.h +++ b/include/spdk/thread.h @@ -267,6 +267,16 @@ uint64_t spdk_thread_next_poller_expiration(struct spdk_thread *thread); */ int spdk_thread_has_active_pollers(struct spdk_thread *thread); +/** + * Returns whether there are any pollers registered to be run + * on the thread. + * + * \param thread The thread to check. + * + * \return true if there is any active poller, false otherwise. + */ +bool spdk_thread_has_pollers(struct spdk_thread *thread); + /** * Get count of allocated threads. */ diff --git a/lib/thread/thread.c b/lib/thread/thread.c index d3ad66c81..f4231bf44 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -549,6 +549,17 @@ spdk_thread_has_active_pollers(struct spdk_thread *thread) return !TAILQ_EMPTY(&thread->active_pollers); } +bool +spdk_thread_has_pollers(struct spdk_thread *thread) +{ + if (TAILQ_EMPTY(&thread->active_pollers) && + TAILQ_EMPTY(&thread->timer_pollers)) { + return false; + } + + return true; +} + uint32_t spdk_thread_get_count(void) {