36 namespace rp{
namespace hal{
63 switch (WaitForSingleObject(
_lock, timeout==0xFFFFFFF?INFINITE:(DWORD)timeout))
79 if (timeout == 0xFFFFFFFF){
83 else if (timeout == 0)
92 gettimeofday(&now,NULL);
94 wait_time.tv_sec = timeout/1000 + now.tv_sec;
95 wait_time.tv_nsec = (timeout%1000)*1000000 + now.tv_usec*1000;
97 if (wait_time.tv_nsec >= 1000000000)
100 wait_time.tv_nsec -= 1000000000;
102 switch (pthread_mutex_timedlock(&
_lock,&wait_time))
123 ReleaseSemaphore(
_lock, 1, NULL);
126 pthread_mutex_unlock(&
_lock);
149 if (_recusive = recusive) {
150 _lock = CreateMutex(NULL, FALSE, NULL);
152 _lock = CreateSemaphore(NULL, 1, 1, NULL);
157 pthread_mutexattr_t attr;
158 pthread_mutexattr_init(&attr);
159 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
160 pthread_mutex_init(&
_lock, &attr);
162 pthread_mutex_init(&
_lock, NULL);
175 pthread_mutex_destroy(&
_lock);