From 3c1b9d9743b3065b19472741db537c36e7cf857d Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Wed, 5 Jan 2011 18:02:09 +0100 Subject: [PATCH] MacOSX port, this needs to be portable... epicsMutex, but there is no timedlock. --- pvAccessApp/utils/referenceCountingLock.cpp | 5 +++++ testApp/utils/namedLockPatternTest.cpp | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pvAccessApp/utils/referenceCountingLock.cpp b/pvAccessApp/utils/referenceCountingLock.cpp index abd2250..11ab0ea 100644 --- a/pvAccessApp/utils/referenceCountingLock.cpp +++ b/pvAccessApp/utils/referenceCountingLock.cpp @@ -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() diff --git a/testApp/utils/namedLockPatternTest.cpp b/testApp/utils/namedLockPatternTest.cpp index 9224800..edbfbbe 100644 --- a/testApp/utils/namedLockPatternTest.cpp +++ b/testApp/utils/namedLockPatternTest.cpp @@ -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 namedGuard(namedLockPattern); assert(!namedGuard.acquireSynchronizationObject(addr,timeout)); } - +#endif return NULL; }