Commit 4e7bb83e authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/444455


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 98104314
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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.
+13 −0
Original line number Diff line number Diff line
@@ -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)
{