mutexDirect.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file mutexDirect.h
  10. * @author drose
  11. * @date 2006-02-13
  12. */
  13. #ifndef MUTEXDIRECT_H
  14. #define MUTEXDIRECT_H
  15. #include "pandabase.h"
  16. #include "mutexTrueImpl.h"
  17. #include "pnotify.h"
  18. class Thread;
  19. #ifndef DEBUG_THREADS
  20. /**
  21. * This class implements a standard mutex by making direct calls to the
  22. * underlying implementation layer. It doesn't perform any debugging
  23. * operations.
  24. */
  25. class EXPCL_PANDA_PIPELINE MutexDirect {
  26. protected:
  27. MutexDirect() = default;
  28. MutexDirect(const MutexDirect &copy) = delete;
  29. ~MutexDirect() = default;
  30. void operator = (const MutexDirect &copy) = delete;
  31. public:
  32. INLINE void lock();
  33. INLINE bool try_lock();
  34. INLINE void unlock();
  35. PUBLISHED:
  36. BLOCKING INLINE void acquire() const;
  37. BLOCKING INLINE bool try_acquire() const;
  38. INLINE void release() const;
  39. INLINE bool debug_is_locked() const;
  40. INLINE void set_name(const std::string &name);
  41. INLINE void clear_name();
  42. INLINE bool has_name() const;
  43. INLINE std::string get_name() const;
  44. void output(std::ostream &out) const;
  45. private:
  46. mutable MutexTrueImpl _impl;
  47. friend class ConditionVarDirect;
  48. };
  49. INLINE std::ostream &
  50. operator << (std::ostream &out, const MutexDirect &m) {
  51. m.output(out);
  52. return out;
  53. }
  54. #include "mutexDirect.I"
  55. #endif // !DEBUG_THREADS
  56. #endif