Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CarlaMutex.cpp 564B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * CarlaMutex Test
  3. */
  4. #include <pthread.h>
  5. class CarlaMutex
  6. {
  7. public:
  8. CarlaMutex()
  9. {
  10. pthread_mutex_init(&fMutex, NULL);
  11. }
  12. ~CarlaMutex()
  13. {
  14. pthread_mutex_destroy(&fMutex);
  15. }
  16. void lock()
  17. {
  18. pthread_mutex_lock(&fMutex);
  19. }
  20. bool tryLock()
  21. {
  22. return (pthread_mutex_trylock(&fMutex) == 0);
  23. }
  24. void unlock()
  25. {
  26. pthread_mutex_unlock(&fMutex);
  27. }
  28. private:
  29. pthread_mutex_t fMutex;
  30. };
  31. int main()
  32. {
  33. CarlaMutex m;
  34. m.tryLock();
  35. m.unlock();
  36. return 0;
  37. }