thread: Add a function to get the thread from a context
This is the inverse of spdk_thread_get_ctx. Change-Id: I81541ff1687cfea358cb7046caf69982c38f6a38 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/c/444455 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
9810431431
commit
4e7bb83e78
@ -222,6 +222,16 @@ void spdk_thread_exit(struct spdk_thread *thread);
|
||||
*/
|
||||
void *spdk_thread_get_ctx(struct spdk_thread *thread);
|
||||
|
||||
/**
|
||||
* Return the thread object associated with the context handle previously
|
||||
* obtained by calling spdk_thread_get_ctx().
|
||||
*
|
||||
* \param ctx A context previously obtained by calling spdk_thread_get_ctx()
|
||||
*
|
||||
* \return The associated thread.
|
||||
*/
|
||||
struct spdk_thread *spdk_thread_get_from_ctx(void *ctx);
|
||||
|
||||
/**
|
||||
* Perform one iteration worth of processing on the thread. This includes
|
||||
* both expired and continuous pollers as well as messages.
|
||||
|
@ -342,6 +342,19 @@ spdk_thread_get_ctx(struct spdk_thread *thread)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct spdk_thread *
|
||||
spdk_thread_get_from_ctx(void *ctx)
|
||||
{
|
||||
if (ctx == NULL) {
|
||||
assert(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
assert(g_ctx_sz > 0);
|
||||
|
||||
return SPDK_CONTAINEROF(ctx, struct spdk_thread, ctx);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
_spdk_msg_queue_run_batch(struct spdk_thread *thread, uint32_t max_msgs)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user