add vcglib

This commit is contained in:
yuanlin zhong committed 2025-11-03 17:46:44 +08:00
1 parent 6f6c0c8eb7
commit af8100f851
1537 files changed
+634197

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
#ifndef MT_MUTEX_H
#define MT_MUTEX_H
#include "base.h"
#include <pthread.h>
namespace mt
{
class condition;
class mutex
{
MT_PREVENT_COPY(mutex)
public:
typedef mutex this_type;
typedef void base_type;
mutex(void)
{
pthread_mutex_init(&(this->m), 0);
}
~mutex(void)
{
pthread_mutex_destroy(&(this->m));
}
void lock(void)
{
pthread_mutex_lock(&(this->m));
}
void unlock(void)
{
pthread_mutex_unlock(&(this->m));
}
bool tryLock(void)
{
int a = pthread_mutex_trylock(&(this->m));
return a == 0;
}
private:
friend class condition;
pthread_mutex_t m;
};
}
#endif // MT_MUTEX_H