diff --git a/include/os/osThread.h b/include/os/osThread.h index 6d8ff1de3e..8a0ace3e77 100644 --- a/include/os/osThread.h +++ b/include/os/osThread.h @@ -32,6 +32,9 @@ typedef pthread_once_t TdThreadOnce; typedef pthread_rwlockattr_t TdThreadRwlockAttr; typedef pthread_cond_t TdThreadCond; typedef pthread_condattr_t TdThreadCondAttr; +typedef pthread_key_t TdThreadKey; +typedef pthread_barrier_t TdThreadBarrier; +typedef pthread_barrierattr_t TdThreadBarrierAttr; #define taosThreadCleanupPush pthread_cleanup_push #define taosThreadCleanupPop pthread_cleanup_pop @@ -79,6 +82,7 @@ typedef pthread_condattr_t TdThreadCondAttr; #define pthread_sigmask PTHREAD_SIGMASK_FUNC_TAOS_FORBID #define pthread_cancel PTHREAD_CANCEL_FUNC_TAOS_FORBID #define pthread_kill PTHREAD_KILL_FUNC_TAOS_FORBID + #define pthread_setname_np PTHREAD_SETNAME_FUNC_TAOS_FORBID #endif int32_t taosThreadSpinInit(TdThreadSpinlock *lock, int pshared); @@ -86,6 +90,7 @@ int32_t taosThreadMutexInit(TdThreadMutex *mutex, const TdThreadMutexAttr *attr) int32_t taosThreadSpinDestroy(TdThreadSpinlock *lock); int32_t taosThreadMutexDestroy(TdThreadMutex * mutex); int32_t taosThreadSpinLock(TdThreadSpinlock *lock); +int32_t taosThreadSpinTryLock(TdThreadSpinlock *lock); int32_t taosThreadMutexLock(TdThreadMutex *mutex); int32_t taosThreadRwlockRdlock(TdThreadRwlock *rwlock); int32_t taosThreadSpinUnlock(TdThreadSpinlock *lock); @@ -111,6 +116,8 @@ int32_t taosThreadEqual(TdThread t1, TdThread t2); int32_t taosThreadSigmask(int how, sigset_t const *set, sigset_t *oset); int32_t taosThreadCancel(TdThread thread); int32_t taosThreadKill(TdThread thread, int sig); +int32_t taosThreadDetach(TdThread thread); + #ifdef __cplusplus } #endif diff --git a/include/os/osTime.h b/include/os/osTime.h index 031b9d28f9..9e426455dc 100644 --- a/include/os/osTime.h +++ b/include/os/osTime.h @@ -20,6 +20,8 @@ extern "C" { #endif +#include + // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following section. #ifndef ALLOW_FORBID_FUNC diff --git a/source/os/src/osThread.c b/source/os/src/osThread.c index 716080274b..386534500f 100644 --- a/source/os/src/osThread.c +++ b/source/os/src/osThread.c @@ -14,6 +14,7 @@ */ #define ALLOW_FORBID_FUNC +#include #include "os.h" // int32_t taosThreadSetnameNp(TdThread thread, const char *name) { @@ -40,6 +41,10 @@ int32_t taosThreadSpinLock(TdThreadSpinlock *lock) { return pthread_spin_lock(lock); } +int32_t taosThreadSpinTryLock(TdThreadSpinlock *lock) { + return pthread_spin_trylock(lock); +} + int32_t taosThreadMutexLock(TdThreadMutex *mutex) { return pthread_mutex_lock(mutex); } @@ -142,4 +147,8 @@ int32_t taosThreadCancel(TdThread thread) { int32_t taosThreadKill(TdThread thread, int sig) { return pthread_kill(thread, sig); +} + +int32_t taosThreadDetach(TdThread thread) { + return pthread_detach(thread); } \ No newline at end of file