Browse Source

Add and use Mutex::wasTryLockCalled() in ScopedProcessLocker

tags/1.9.4
falkTX 12 years ago
parent
commit
0e9a47a026
2 changed files with 13 additions and 1 deletions
  1. +2
    -1
      source/backend/plugin/CarlaPlugin.cpp
  2. +11
    -0
      source/utils/CarlaMutex.hpp

+ 2
- 1
source/backend/plugin/CarlaPlugin.cpp View File

@@ -1505,7 +1505,8 @@ CarlaPlugin::ScopedProcessLocker::~ScopedProcessLocker()

if (kBlock)
{
kPlugin->kData->needsReset = true;
if (kPlugin->kData->mutex.wasTryLockCalled())
kPlugin->kData->needsReset = true;
kPlugin->kData->mutex.unlock();
}
}


+ 11
- 0
source/utils/CarlaMutex.hpp View File

@@ -35,6 +35,7 @@ class CarlaMutex
{
public:
CarlaMutex()
: fTryLockCalled(false)
{
#ifndef CPP11_MUTEX
pthread_mutex_init(&pmutex, nullptr);
@@ -59,6 +60,8 @@ public:

bool tryLock()
{
fTryLockCalled = true;

#ifdef CPP11_MUTEX
return cmutex.try_lock();
#else
@@ -75,6 +78,13 @@ public:
#endif
}

bool wasTryLockCalled()
{
const bool ret = fTryLockCalled;
fTryLockCalled = false;
return ret;
}

class ScopedLocker
{
public:
@@ -102,6 +112,7 @@ private:
#else
pthread_mutex_t pmutex;
#endif
bool fTryLockCalled;

CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaMutex)


Loading…
Cancel
Save