qmutexlocker.sip 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // This is the SIP interface definition for the QMutexLocker class.
  2. //
  3. // In Qt6 this is a template so we wrap our own class that implements the Qt5
  4. // API.
  5. //
  6. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  7. //
  8. // This file is part of PyQt6.
  9. //
  10. // This file may be used under the terms of the GNU General Public License
  11. // version 3.0 as published by the Free Software Foundation and appearing in
  12. // the file LICENSE included in the packaging of this file. Please review the
  13. // following information to ensure the GNU General Public License version 3.0
  14. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  15. //
  16. // If you do not wish to use this file under the terms of the GPL version 3.0
  17. // then you may purchase a commercial license. For more information contact
  18. // info@riverbankcomputing.com.
  19. //
  20. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  21. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  22. class PyQtMutexLocker /PyName=QMutexLocker/
  23. {
  24. %TypeHeaderCode
  25. #include "qpycore_pyqtmutexlocker.h"
  26. %End
  27. public:
  28. PyQtMutexLocker(QMutex *mutex /GetWrapper/) /ReleaseGIL/;
  29. %MethodCode
  30. Py_BEGIN_ALLOW_THREADS
  31. sipCpp = new PyQtMutexLocker(a0, a0Wrapper);
  32. Py_END_ALLOW_THREADS
  33. %End
  34. PyQtMutexLocker(QRecursiveMutex *mutex /GetWrapper/) /ReleaseGIL/;
  35. %MethodCode
  36. Py_BEGIN_ALLOW_THREADS
  37. sipCpp = new PyQtMutexLocker(a0, a0Wrapper);
  38. Py_END_ALLOW_THREADS
  39. %End
  40. ~PyQtMutexLocker();
  41. SIP_PYOBJECT mutex() /TypeHint="Union[QMutex, QRecursiveMutex]"/;
  42. void unlock() /ReleaseGIL/;
  43. void relock() /ReleaseGIL/;
  44. SIP_PYOBJECT __enter__();
  45. %MethodCode
  46. // Just return a reference to self.
  47. sipRes = sipSelf;
  48. Py_INCREF(sipRes);
  49. %End
  50. void __exit__(SIP_PYOBJECT type, SIP_PYOBJECT value, SIP_PYOBJECT traceback);
  51. %MethodCode
  52. sipCpp->unlock();
  53. %End
  54. private:
  55. PyQtMutexLocker(const PyQtMutexLocker &);
  56. };