FS-10167 track joins and only do them once
This commit is contained in:
parent
52f1451ece
commit
020f80b8d2
|
@ -78,6 +78,7 @@ struct ks_thread {
|
|||
ks_thread_state_t state;
|
||||
uint8_t priority;
|
||||
void *return_data;
|
||||
uint8_t joined;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -89,6 +89,7 @@ KS_BEGIN_EXTERN_C
|
|||
KS_STATUS_GENERR,
|
||||
KS_STATUS_INACTIVE,
|
||||
KS_STATUS_TIMEOUT,
|
||||
KS_STATUS_DUPLICATE_OPERATION,
|
||||
/* Memory pool errors */
|
||||
KS_STATUS_REFS_EXIST, /* references exist */
|
||||
KS_STATUS_ARG_NULL, /* function argument is null */
|
||||
|
|
|
@ -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) {
|
||||
|
||||
if (thread->joined) {
|
||||
return KS_STATUS_DUPLICATE_OPERATION;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
WaitForSingleObject(thread->handle, INFINITE);
|
||||
#else
|
||||
void *ret;
|
||||
pthread_join(thread->handle, &ret);
|
||||
#endif
|
||||
|
||||
thread->joined++;
|
||||
|
||||
return KS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue