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: Jim Harris <james.r.harris@intel.com> Change-Id: I2f6fb024a6b1bc895fdc5132c722abc10f5d30f9 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15512 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
parent
98ceddb47c
commit
8203e68e24
@ -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
|
Added `spdk_thread_get_app_thread` which returns the first thread that was created using
|
||||||
`spdk_thread_create`.
|
`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
|
## v22.09
|
||||||
|
|
||||||
### accel
|
### accel
|
||||||
|
@ -285,12 +285,28 @@ int spdk_thread_exit(struct spdk_thread *thread);
|
|||||||
/**
|
/**
|
||||||
* Returns whether the thread is marked as exited.
|
* 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.
|
* \param thread The thread to query.
|
||||||
*
|
*
|
||||||
* \return true if marked as exited, false otherwise.
|
* \return true if marked as exited, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool spdk_thread_is_exited(struct spdk_thread *thread);
|
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
|
* Destroy a thread, releasing all of its resources. May only be called
|
||||||
* on a thread previously marked as exited.
|
* on a thread previously marked as exited.
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
spdk_thread_get_app_thread;
|
spdk_thread_get_app_thread;
|
||||||
spdk_set_thread;
|
spdk_set_thread;
|
||||||
spdk_thread_exit;
|
spdk_thread_exit;
|
||||||
|
spdk_thread_is_running;
|
||||||
spdk_thread_is_exited;
|
spdk_thread_is_exited;
|
||||||
spdk_thread_destroy;
|
spdk_thread_destroy;
|
||||||
spdk_thread_get_ctx;
|
spdk_thread_get_ctx;
|
||||||
|
@ -594,6 +594,12 @@ spdk_thread_exit(struct spdk_thread *thread)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
spdk_thread_is_running(struct spdk_thread *thread)
|
||||||
|
{
|
||||||
|
return thread->state == SPDK_THREAD_STATE_RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
spdk_thread_is_exited(struct spdk_thread *thread)
|
spdk_thread_is_exited(struct spdk_thread *thread)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user