Commit 8203e68e authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

thread: add spdk_thread_is_running()



This function can be useful to query if a thread
had spdk_thread_exit() called on it yet.  Internally
we have both EXITING and EXITED state - so
!spdk_thread_is_running() can be used to detect a
thread that is in either of those states.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I2f6fb024a6b1bc895fdc5132c722abc10f5d30f9
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15512


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 98ceddb4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -70,6 +70,9 @@ for writing and decoding of the the double data type.
Added `spdk_thread_get_app_thread` which returns the first thread that was created using
`spdk_thread_create`.

Added `spdk_thread_is_running`.  This returns `true` for a running thread, or `false` if
its exit process has started using `spdk_thread_exit`.

## v22.09

### accel
+16 −0
Original line number Diff line number Diff line
@@ -285,12 +285,28 @@ int spdk_thread_exit(struct spdk_thread *thread);
/**
 * Returns whether the thread is marked as exited.
 *
 * A thread is exited only after it has spdk_thread_exit() called on it, and
 * it has been polled until any outstanding operations targeting this
 * thread have completed.  This may include poller unregistrations, io channel
 * unregistrations, or outstanding spdk_thread_send_msg calls.
 *
 * \param thread The thread to query.
 *
 * \return true if marked as exited, false otherwise.
 */
bool spdk_thread_is_exited(struct spdk_thread *thread);

/**
 * Returns whether the thread is still running.
 *
 * A thread is considered running until it has * spdk_thread_exit() called on it.
 *
 * \param thread The thread to query.
 *
 * \return true if still running, false otherwise.
 */
bool spdk_thread_is_running(struct spdk_thread *thread);

/**
 * Destroy a thread, releasing all of its resources. May only be called
 * on a thread previously marked as exited.
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
	spdk_thread_get_app_thread;
	spdk_set_thread;
	spdk_thread_exit;
	spdk_thread_is_running;
	spdk_thread_is_exited;
	spdk_thread_destroy;
	spdk_thread_get_ctx;
+6 −0
Original line number Diff line number Diff line
@@ -594,6 +594,12 @@ spdk_thread_exit(struct spdk_thread *thread)
	return 0;
}

bool
spdk_thread_is_running(struct spdk_thread *thread)
{
	return thread->state == SPDK_THREAD_STATE_RUNNING;
}

bool
spdk_thread_is_exited(struct spdk_thread *thread)
{