2024-08-25 04:08:24 +00:00
|
|
|
package qt
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
#include "gen_qreadwritelock.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
2024-09-14 22:29:05 +00:00
|
|
|
"runtime"
|
2024-08-25 04:08:24 +00:00
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
type QReadWriteLock__RecursionMode int
|
|
|
|
|
|
|
|
const (
|
2024-09-20 07:13:26 +00:00
|
|
|
QReadWriteLock__NonRecursive QReadWriteLock__RecursionMode = 0
|
|
|
|
QReadWriteLock__Recursive QReadWriteLock__RecursionMode = 1
|
2024-09-04 06:54:22 +00:00
|
|
|
)
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
type QReadWriteLock struct {
|
|
|
|
h *C.QReadWriteLock
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QReadWriteLock) cPointer() *C.QReadWriteLock {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
|
|
|
func newQReadWriteLock(h *C.QReadWriteLock) *QReadWriteLock {
|
2024-09-01 02:23:55 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-08-25 04:08:24 +00:00
|
|
|
return &QReadWriteLock{h: h}
|
|
|
|
}
|
|
|
|
|
|
|
|
func newQReadWriteLock_U(h unsafe.Pointer) *QReadWriteLock {
|
|
|
|
return newQReadWriteLock((*C.QReadWriteLock)(h))
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
// NewQReadWriteLock constructs a new QReadWriteLock object.
|
|
|
|
func NewQReadWriteLock() *QReadWriteLock {
|
|
|
|
ret := C.QReadWriteLock_new()
|
|
|
|
return newQReadWriteLock(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewQReadWriteLock2 constructs a new QReadWriteLock object.
|
2024-09-04 06:54:22 +00:00
|
|
|
func NewQReadWriteLock2(recursionMode QReadWriteLock__RecursionMode) *QReadWriteLock {
|
2024-09-18 00:12:02 +00:00
|
|
|
ret := C.QReadWriteLock_new2((C.int)(recursionMode))
|
2024-08-29 07:01:51 +00:00
|
|
|
return newQReadWriteLock(ret)
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QReadWriteLock) LockForRead() {
|
|
|
|
C.QReadWriteLock_LockForRead(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QReadWriteLock) TryLockForRead() bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QReadWriteLock_TryLockForRead(this.h))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QReadWriteLock) TryLockForReadWithTimeout(timeout int) bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QReadWriteLock_TryLockForReadWithTimeout(this.h, (C.int)(timeout)))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QReadWriteLock) LockForWrite() {
|
|
|
|
C.QReadWriteLock_LockForWrite(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QReadWriteLock) TryLockForWrite() bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QReadWriteLock_TryLockForWrite(this.h))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QReadWriteLock) TryLockForWriteWithTimeout(timeout int) bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QReadWriteLock_TryLockForWriteWithTimeout(this.h, (C.int)(timeout)))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QReadWriteLock) Unlock() {
|
|
|
|
C.QReadWriteLock_Unlock(this.h)
|
|
|
|
}
|
|
|
|
|
2024-09-14 22:29:05 +00:00
|
|
|
// Delete this object from C++ memory.
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QReadWriteLock) Delete() {
|
|
|
|
C.QReadWriteLock_Delete(this.h)
|
|
|
|
}
|
|
|
|
|
2024-09-14 22:29:05 +00:00
|
|
|
// GoGC adds a Go Finalizer to this pointer, so that it will be deleted
|
|
|
|
// from C++ memory once it is unreachable from Go memory.
|
|
|
|
func (this *QReadWriteLock) GoGC() {
|
|
|
|
runtime.SetFinalizer(this, func(this *QReadWriteLock) {
|
|
|
|
this.Delete()
|
|
|
|
runtime.KeepAlive(this.h)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
type QReadLocker struct {
|
|
|
|
h *C.QReadLocker
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QReadLocker) cPointer() *C.QReadLocker {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
|
|
|
func newQReadLocker(h *C.QReadLocker) *QReadLocker {
|
2024-09-01 02:23:55 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-08-25 04:08:24 +00:00
|
|
|
return &QReadLocker{h: h}
|
|
|
|
}
|
|
|
|
|
|
|
|
func newQReadLocker_U(h unsafe.Pointer) *QReadLocker {
|
|
|
|
return newQReadLocker((*C.QReadLocker)(h))
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewQReadLocker constructs a new QReadLocker object.
|
|
|
|
func NewQReadLocker(readWriteLock *QReadWriteLock) *QReadLocker {
|
|
|
|
ret := C.QReadLocker_new(readWriteLock.cPointer())
|
|
|
|
return newQReadLocker(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QReadLocker) Unlock() {
|
|
|
|
C.QReadLocker_Unlock(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QReadLocker) Relock() {
|
|
|
|
C.QReadLocker_Relock(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QReadLocker) ReadWriteLock() *QReadWriteLock {
|
2024-09-17 07:30:27 +00:00
|
|
|
return newQReadWriteLock_U(unsafe.Pointer(C.QReadLocker_ReadWriteLock(this.h)))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-14 22:29:05 +00:00
|
|
|
// Delete this object from C++ memory.
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QReadLocker) Delete() {
|
|
|
|
C.QReadLocker_Delete(this.h)
|
|
|
|
}
|
|
|
|
|
2024-09-14 22:29:05 +00:00
|
|
|
// GoGC adds a Go Finalizer to this pointer, so that it will be deleted
|
|
|
|
// from C++ memory once it is unreachable from Go memory.
|
|
|
|
func (this *QReadLocker) GoGC() {
|
|
|
|
runtime.SetFinalizer(this, func(this *QReadLocker) {
|
|
|
|
this.Delete()
|
|
|
|
runtime.KeepAlive(this.h)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
type QWriteLocker struct {
|
|
|
|
h *C.QWriteLocker
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QWriteLocker) cPointer() *C.QWriteLocker {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
|
|
|
func newQWriteLocker(h *C.QWriteLocker) *QWriteLocker {
|
2024-09-01 02:23:55 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-08-25 04:08:24 +00:00
|
|
|
return &QWriteLocker{h: h}
|
|
|
|
}
|
|
|
|
|
|
|
|
func newQWriteLocker_U(h unsafe.Pointer) *QWriteLocker {
|
|
|
|
return newQWriteLocker((*C.QWriteLocker)(h))
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewQWriteLocker constructs a new QWriteLocker object.
|
|
|
|
func NewQWriteLocker(readWriteLock *QReadWriteLock) *QWriteLocker {
|
|
|
|
ret := C.QWriteLocker_new(readWriteLock.cPointer())
|
|
|
|
return newQWriteLocker(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QWriteLocker) Unlock() {
|
|
|
|
C.QWriteLocker_Unlock(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QWriteLocker) Relock() {
|
|
|
|
C.QWriteLocker_Relock(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QWriteLocker) ReadWriteLock() *QReadWriteLock {
|
2024-09-17 07:30:27 +00:00
|
|
|
return newQReadWriteLock_U(unsafe.Pointer(C.QWriteLocker_ReadWriteLock(this.h)))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-14 22:29:05 +00:00
|
|
|
// Delete this object from C++ memory.
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QWriteLocker) Delete() {
|
|
|
|
C.QWriteLocker_Delete(this.h)
|
|
|
|
}
|
2024-09-14 22:29:05 +00:00
|
|
|
|
|
|
|
// GoGC adds a Go Finalizer to this pointer, so that it will be deleted
|
|
|
|
// from C++ memory once it is unreachable from Go memory.
|
|
|
|
func (this *QWriteLocker) GoGC() {
|
|
|
|
runtime.SetFinalizer(this, func(this *QWriteLocker) {
|
|
|
|
this.Delete()
|
|
|
|
runtime.KeepAlive(this.h)
|
|
|
|
})
|
|
|
|
}
|