提交 020f80b8 authored 作者: Anthony Minessale's avatar Anthony Minessale

FS-10167 track joins and only do them once

上级 52f1451e
...@@ -78,6 +78,7 @@ struct ks_thread { ...@@ -78,6 +78,7 @@ struct ks_thread {
ks_thread_state_t state; ks_thread_state_t state;
uint8_t priority; uint8_t priority;
void *return_data; void *return_data;
uint8_t joined;
}; };
typedef enum { typedef enum {
......
...@@ -89,6 +89,7 @@ KS_BEGIN_EXTERN_C ...@@ -89,6 +89,7 @@ KS_BEGIN_EXTERN_C
KS_STATUS_GENERR, KS_STATUS_GENERR,
KS_STATUS_INACTIVE, KS_STATUS_INACTIVE,
KS_STATUS_TIMEOUT, KS_STATUS_TIMEOUT,
KS_STATUS_DUPLICATE_OPERATION,
/* Memory pool errors */ /* Memory pool errors */
KS_STATUS_REFS_EXIST, /* references exist */ KS_STATUS_REFS_EXIST, /* references exist */
KS_STATUS_ARG_NULL, /* function argument is null */ KS_STATUS_ARG_NULL, /* function argument is null */
......
...@@ -197,12 +197,20 @@ KS_DECLARE(uint8_t) ks_thread_priority(ks_thread_t *thread) { ...@@ -197,12 +197,20 @@ KS_DECLARE(uint8_t) ks_thread_priority(ks_thread_t *thread) {
} }
KS_DECLARE(ks_status_t) ks_thread_join(ks_thread_t *thread) { KS_DECLARE(ks_status_t) ks_thread_join(ks_thread_t *thread) {
if (thread->joined) {
return KS_STATUS_DUPLICATE_OPERATION;
}
#ifdef WIN32 #ifdef WIN32
WaitForSingleObject(thread->handle, INFINITE); WaitForSingleObject(thread->handle, INFINITE);
#else #else
void *ret; void *ret;
pthread_join(thread->handle, &ret); pthread_join(thread->handle, &ret);
#endif #endif
thread->joined++;
return KS_STATUS_SUCCESS; return KS_STATUS_SUCCESS;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论