qreadwritelock.sip 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // qreadwritelock.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtCore Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QReadWriteLock
  22. {
  23. %TypeHeaderCode
  24. #include <qreadwritelock.h>
  25. %End
  26. public:
  27. enum RecursionMode
  28. {
  29. NonRecursive,
  30. Recursive,
  31. };
  32. explicit QReadWriteLock(QReadWriteLock::RecursionMode recursionMode = QReadWriteLock::NonRecursive);
  33. ~QReadWriteLock();
  34. void lockForRead() /ReleaseGIL/;
  35. %If (Qt_6_6_0 -)
  36. bool tryLockForRead(QDeadlineTimer timeout = {}) /ReleaseGIL/;
  37. %End
  38. %If (- Qt_6_6_0)
  39. bool tryLockForRead();
  40. %End
  41. bool tryLockForRead(int timeout) /ReleaseGIL/;
  42. void lockForWrite() /ReleaseGIL/;
  43. %If (Qt_6_6_0 -)
  44. bool tryLockForWrite(QDeadlineTimer timeout = {}) /ReleaseGIL/;
  45. %End
  46. %If (- Qt_6_6_0)
  47. bool tryLockForWrite();
  48. %End
  49. bool tryLockForWrite(int timeout) /ReleaseGIL/;
  50. void unlock();
  51. private:
  52. QReadWriteLock(const QReadWriteLock &);
  53. };
  54. class QReadLocker
  55. {
  56. %TypeHeaderCode
  57. #include <qreadwritelock.h>
  58. %End
  59. public:
  60. QReadLocker(QReadWriteLock *areadWriteLock) /ReleaseGIL/;
  61. ~QReadLocker();
  62. void unlock();
  63. void relock() /ReleaseGIL/;
  64. QReadWriteLock *readWriteLock() const;
  65. SIP_PYOBJECT __enter__();
  66. %MethodCode
  67. // Just return a reference to self.
  68. sipRes = sipSelf;
  69. Py_INCREF(sipRes);
  70. %End
  71. void __exit__(SIP_PYOBJECT type, SIP_PYOBJECT value, SIP_PYOBJECT traceback);
  72. %MethodCode
  73. sipCpp->unlock();
  74. %End
  75. private:
  76. QReadLocker(const QReadLocker &);
  77. };
  78. class QWriteLocker
  79. {
  80. %TypeHeaderCode
  81. #include <qreadwritelock.h>
  82. %End
  83. public:
  84. QWriteLocker(QReadWriteLock *areadWriteLock) /ReleaseGIL/;
  85. ~QWriteLocker();
  86. void unlock();
  87. void relock() /ReleaseGIL/;
  88. QReadWriteLock *readWriteLock() const;
  89. SIP_PYOBJECT __enter__();
  90. %MethodCode
  91. // Just return a reference to self.
  92. sipRes = sipSelf;
  93. Py_INCREF(sipRes);
  94. %End
  95. void __exit__(SIP_PYOBJECT type, SIP_PYOBJECT value, SIP_PYOBJECT traceback);
  96. %MethodCode
  97. sipCpp->unlock();
  98. %End
  99. private:
  100. QWriteLocker(const QWriteLocker &);
  101. };