reMutex.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 reMutex.h
  10. * @author drose
  11. * @date 2006-01-15
  12. */
  13. #ifndef REMUTEX_H
  14. #define REMUTEX_H
  15. #include "pandabase.h"
  16. #include "mutexDebug.h"
  17. #include "reMutexDirect.h"
  18. /**
  19. * A reentrant mutex. This kind of mutex can be locked more than once by the
  20. * thread that already holds it, without deadlock. The thread must eventually
  21. * release the mutex the same number of times it locked it.
  22. *
  23. * This class inherits its implementation either from MutexDebug or
  24. * ReMutexDirect, depending on the definition of DEBUG_THREADS.
  25. */
  26. #ifdef DEBUG_THREADS
  27. class EXPCL_PANDA_PIPELINE ReMutex : public MutexDebug
  28. #else
  29. class EXPCL_PANDA_PIPELINE ReMutex : public ReMutexDirect
  30. #endif // DEBUG_THREADS
  31. {
  32. PUBLISHED:
  33. INLINE ReMutex();
  34. public:
  35. INLINE explicit ReMutex(const char *name);
  36. PUBLISHED:
  37. INLINE explicit ReMutex(const std::string &name);
  38. ReMutex(const ReMutex &copy) = delete;
  39. ~ReMutex() = default;
  40. void operator = (const ReMutex &copy) = delete;
  41. EXTENSION(bool acquire(bool blocking=true) const);
  42. EXTENSION(bool __enter__());
  43. EXTENSION(void __exit__(PyObject *, PyObject *, PyObject *));
  44. };
  45. #include "reMutex.I"
  46. #endif