Improved thread id documentation and added odp_thread_count(), which returns number of active threads.
Signed-off-by: Petri Savolainen <[email protected]> --- include/odp/api/thread.h | 17 +++++++++++++++++ platform/linux-generic/odp_thread.c | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/include/odp/api/thread.h b/include/odp/api/thread.h index 844f45a..6b3b39b 100644 --- a/include/odp/api/thread.h +++ b/include/odp/api/thread.h @@ -25,11 +25,28 @@ extern "C" { /** * Get thread identifier * + * Returns the thread identifier of the current thread. Thread ids range from 0 + * to ODP_CONFIG_MAX_THREADS-1. The ODP thread id is assinged by + * odp_init_local() and freed by odp_term_local(). Thread id is unique within + * the ODP instance. + * * @return Thread identifier of the current thread */ int odp_thread_id(void); /** + * Thread count + * + * Returns the current ODP thread count. This is the number of active threads + * running the ODP instance. Each odp_init_local() call increments and each + * odp_term_local() call decrements the count. The count is always between 1 and + * ODP_CONFIG_MAX_THREADS. + * + * @return Current thread count + */ +int odp_thread_count(void); + +/** * @} */ diff --git a/platform/linux-generic/odp_thread.c b/platform/linux-generic/odp_thread.c index ac8c9de..f6c900b 100644 --- a/platform/linux-generic/odp_thread.c +++ b/platform/linux-generic/odp_thread.c @@ -118,6 +118,10 @@ int odp_thread_id(void) return this_thread->thr_id; } +int odp_thread_count(void) +{ + return odp_atomic_load_u32(&thread_globals->num); +} int odp_cpu_id(void) { -- 2.2.2 _______________________________________________ lng-odp mailing list [email protected] http://lists.linaro.org/mailman/listinfo/lng-odp
