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.

75 lines
1.5KB

  1. #ifndef STK_MUTEX_H
  2. #define STK_MUTEX_H
  3. #include "Stk.h"
  4. #if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
  5. #include <pthread.h>
  6. typedef pthread_mutex_t MUTEX;
  7. typedef pthread_cond_t CONDITION;
  8. #elif defined(__OS_WINDOWS__)
  9. #include <windows.h>
  10. #include <process.h>
  11. typedef CRITICAL_SECTION MUTEX;
  12. typedef HANDLE CONDITION;
  13. #endif
  14. namespace stk {
  15. /***************************************************/
  16. /*! \class Mutex
  17. \brief STK mutex class.
  18. This class provides a uniform interface for
  19. cross-platform mutex use. On Linux and IRIX
  20. systems, the pthread library is used. Under
  21. Windows, critical sections are used.
  22. by Perry R. Cook and Gary P. Scavone, 1995-2011.
  23. */
  24. /***************************************************/
  25. class Mutex : public Stk
  26. {
  27. public:
  28. //! Default constructor.
  29. Mutex();
  30. //! Class destructor.
  31. ~Mutex();
  32. //! Lock the mutex.
  33. void lock(void);
  34. //! Unlock the mutex.
  35. void unlock(void);
  36. //! Wait indefinitely on the mutex condition variable.
  37. /*!
  38. The mutex must be locked before calling this function, and then
  39. subsequently unlocked after this function returns.
  40. */
  41. void wait(void);
  42. //! Signal the condition variable.
  43. /*!
  44. The mutex must be locked before calling this function, and then
  45. subsequently unlocked after this function returns.
  46. */
  47. void signal(void);
  48. protected:
  49. MUTEX mutex_;
  50. CONDITION condition_;
  51. };
  52. } // stk namespace
  53. #endif