MacOSX port, this needs to be portable... epicsMutex, but there is no timedlock.

This commit is contained in:
Matej Sekoranja
2011-01-05 18:02:09 +01:00
parent 0af1781b5e
commit 3c1b9d9743
2 changed files with 7 additions and 2 deletions

View File

@@ -41,6 +41,10 @@ ReferenceCountingLock::~ReferenceCountingLock()
bool ReferenceCountingLock::acquire(int64 msecs)
{
#ifdef darwin
// timedlock not supported by Darwin OS
return (pthread_mutex_lock(&_mutex) == 0);
#else
struct timespec deltatime;
deltatime.tv_sec = msecs / 1000;
deltatime.tv_nsec = (msecs % 1000) * 1000;
@@ -51,6 +55,7 @@ bool ReferenceCountingLock::acquire(int64 msecs)
return true;
}
return false;
#endif
}
void ReferenceCountingLock::release()

View File

@@ -156,7 +156,7 @@ void* testWorker2(void* p)
assert(namedGuard.acquireSynchronizationObject(addr,timeout));
usleep(1);
}
#ifndef darwin
//this thread sleeps a while and gets timeout on lock
{
sleep(1);
@@ -167,7 +167,7 @@ void* testWorker2(void* p)
NamedLock<osiSockAddr,comp_osiSockAddr> namedGuard(namedLockPattern);
assert(!namedGuard.acquireSynchronizationObject(addr,timeout));
}
#endif
return NULL;
}