Update StarThread_unix.cpp
This commit is contained in:
parent
295ed51126
commit
d7065e7611
@ -131,12 +131,16 @@ struct MutexImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void lock() {
|
void lock() {
|
||||||
|
#ifndef STAR_SYSTEM_MACOS
|
||||||
timespec ts;
|
timespec ts;
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
ts.tv_sec += 60;
|
ts.tv_sec += 60;
|
||||||
if (pthread_mutex_timedlock(&mutex, &ts) != 0) {
|
if (pthread_mutex_timedlock(&mutex, &ts) != 0) {
|
||||||
Logger::warn("Mutex lock is taking too long, printing stack");
|
Logger::warn("Mutex lock is taking too long, printing stack");
|
||||||
printStack("Mutex::lock");
|
printStack("Mutex::lock");
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
pthread_mutex_lock(&mutex);
|
pthread_mutex_lock(&mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,12 +210,16 @@ struct RecursiveMutexImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void lock() {
|
void lock() {
|
||||||
|
#ifndef STAR_SYSTEM_MACOS
|
||||||
timespec ts;
|
timespec ts;
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
ts.tv_sec += 60;
|
ts.tv_sec += 60;
|
||||||
if (pthread_mutex_timedlock(&mutex, &ts) != 0) {
|
if (pthread_mutex_timedlock(&mutex, &ts) != 0) {
|
||||||
Logger::warn("RecursiveMutex lock is taking too long, printing stack");
|
Logger::warn("RecursiveMutex lock is taking too long, printing stack");
|
||||||
printStack("RecursiveMutex::lock");
|
printStack("RecursiveMutex::lock");
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
pthread_mutex_lock(&mutex);
|
pthread_mutex_lock(&mutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user