Update StarThread_unix.cpp

This commit is contained in:
Kae 2024-08-14 16:51:58 +10:00
parent 295ed51126
commit d7065e7611

View File

@ -131,12 +131,16 @@ struct MutexImpl {
}
void lock() {
#ifndef STAR_SYSTEM_MACOS
timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += 60;
if (pthread_mutex_timedlock(&mutex, &ts) != 0) {
Logger::warn("Mutex lock is taking too long, printing stack");
printStack("Mutex::lock");
#else
{
#endif
pthread_mutex_lock(&mutex);
}
}
@ -206,12 +210,16 @@ struct RecursiveMutexImpl {
}
void lock() {
#ifndef STAR_SYSTEM_MACOS
timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += 60;
if (pthread_mutex_timedlock(&mutex, &ts) != 0) {
Logger::warn("RecursiveMutex lock is taking too long, printing stack");
printStack("RecursiveMutex::lock");
#else
{
#endif
pthread_mutex_lock(&mutex);
}
}