Browse Source

More misc changes

tags/1.9.4
falkTX 12 years ago
parent
commit
ce41033d02
1 changed files with 13 additions and 15 deletions
  1. +13
    -15
      source/utils/carla_utils.hpp

+ 13
- 15
source/utils/carla_utils.hpp View File

@@ -24,7 +24,7 @@
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>


#ifdef DONT_USE_PTHREAD
#ifdef CPP11_MUTEX
# include <mutex> # include <mutex>
#else #else
# include <pthread.h> # include <pthread.h>
@@ -219,44 +219,42 @@ class CarlaMutex
public: public:
CarlaMutex() CarlaMutex()
{ {
#ifndef DONT_USE_PTHREAD
#ifndef CPP11_MUTEX
pthread_mutex_init(&pmutex, nullptr); pthread_mutex_init(&pmutex, nullptr);
#endif #endif
} }


~CarlaMutex() ~CarlaMutex()
{ {
#ifndef DONT_USE_PTHREAD
#ifndef CPP11_MUTEX
pthread_mutex_destroy(&pmutex); pthread_mutex_destroy(&pmutex);
#endif #endif
} }


bool lock()
void lock()
{ {
#ifdef DONT_USE_PTHREAD
#ifdef CPP11_MUTEX
cmutex.lock(); cmutex.lock();
return true;
#else #else
return (pthread_mutex_lock(&pmutex) == 0);
pthread_mutex_lock(&pmutex);
#endif #endif
} }


bool tryLock() bool tryLock()
{ {
#ifdef DONT_USE_PTHREAD
#ifdef CPP11_MUTEX
return cmutex.try_lock(); return cmutex.try_lock();
#else #else
return (pthread_mutex_trylock(&pmutex) == 0); return (pthread_mutex_trylock(&pmutex) == 0);
#endif #endif
} }


bool unlock()
void unlock()
{ {
#ifdef DONT_USE_PTHREAD
#ifdef CPP11_MUTEX
cmutex.unlock(); cmutex.unlock();
return true;
#else #else
return (pthread_mutex_unlock(&pmutex) == 0);
pthread_mutex_unlock(&pmutex);
#endif #endif
} }


@@ -282,7 +280,7 @@ public:
}; };


private: private:
#ifdef DONT_USE_PTHREAD
#ifdef CPP11_MUTEX
std::mutex cmutex; std::mutex cmutex;
#else #else
pthread_mutex_t pmutex; pthread_mutex_t pmutex;
@@ -414,14 +412,14 @@ public:
return (bufferLen != 0); return (bufferLen != 0);
} }


#if __USE_GNU && 0
#if __USE_GNU
bool contains(const char* const strBuf, const bool ignoreCase = false) const bool contains(const char* const strBuf, const bool ignoreCase = false) const
{ {
if (strBuf == nullptr) if (strBuf == nullptr)
return false; return false;


if (ignoreCase) if (ignoreCase)
return (std::strcasestr(buffer, strBuf) != nullptr);
return (strcasestr(buffer, strBuf) != nullptr);
else else
return (std::strstr(buffer, strBuf) != nullptr); return (std::strstr(buffer, strBuf) != nullptr);
} }


Loading…
Cancel
Save