2024-10-20 05:21:03 +00:00
|
|
|
package qt6
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
#include "gen_qmutex.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
type QBasicMutex struct {
|
2024-11-19 06:29:06 +00:00
|
|
|
h *C.QBasicMutex
|
|
|
|
isSubclass bool
|
2024-10-20 05:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QBasicMutex) cPointer() *C.QBasicMutex {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QBasicMutex) UnsafePointer() unsafe.Pointer {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return unsafe.Pointer(this.h)
|
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
// newQBasicMutex constructs the type using only CGO pointers.
|
2024-10-20 05:21:03 +00:00
|
|
|
func newQBasicMutex(h *C.QBasicMutex) *QBasicMutex {
|
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return &QBasicMutex{h: h}
|
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
// UnsafeNewQBasicMutex constructs the type using only unsafe pointers.
|
2024-10-20 05:21:03 +00:00
|
|
|
func UnsafeNewQBasicMutex(h unsafe.Pointer) *QBasicMutex {
|
2024-11-19 06:29:06 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &QBasicMutex{h: (*C.QBasicMutex)(h)}
|
2024-10-20 05:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewQBasicMutex constructs a new QBasicMutex object.
|
|
|
|
func NewQBasicMutex() *QBasicMutex {
|
2024-11-19 06:29:06 +00:00
|
|
|
var outptr_QBasicMutex *C.QBasicMutex = nil
|
|
|
|
|
|
|
|
C.QBasicMutex_new(&outptr_QBasicMutex)
|
|
|
|
ret := newQBasicMutex(outptr_QBasicMutex)
|
|
|
|
ret.isSubclass = true
|
|
|
|
return ret
|
2024-10-20 05:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QBasicMutex) Lock() {
|
|
|
|
C.QBasicMutex_Lock(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QBasicMutex) Unlock() {
|
|
|
|
C.QBasicMutex_Unlock(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QBasicMutex) TryLock() bool {
|
|
|
|
return (bool)(C.QBasicMutex_TryLock(this.h))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QBasicMutex) TryLock2() bool {
|
|
|
|
return (bool)(C.QBasicMutex_TryLock2(this.h))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete this object from C++ memory.
|
|
|
|
func (this *QBasicMutex) Delete() {
|
2024-11-19 06:29:06 +00:00
|
|
|
C.QBasicMutex_Delete(this.h, C.bool(this.isSubclass))
|
2024-10-20 05:21:03 +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 *QBasicMutex) GoGC() {
|
|
|
|
runtime.SetFinalizer(this, func(this *QBasicMutex) {
|
|
|
|
this.Delete()
|
|
|
|
runtime.KeepAlive(this.h)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
type QMutex struct {
|
2024-11-19 06:29:06 +00:00
|
|
|
h *C.QMutex
|
|
|
|
isSubclass bool
|
2024-10-20 05:21:03 +00:00
|
|
|
*QBasicMutex
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMutex) cPointer() *C.QMutex {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMutex) UnsafePointer() unsafe.Pointer {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return unsafe.Pointer(this.h)
|
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
// newQMutex constructs the type using only CGO pointers.
|
|
|
|
func newQMutex(h *C.QMutex, h_QBasicMutex *C.QBasicMutex) *QMutex {
|
2024-10-20 05:21:03 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-11-19 06:29:06 +00:00
|
|
|
return &QMutex{h: h,
|
|
|
|
QBasicMutex: newQBasicMutex(h_QBasicMutex)}
|
2024-10-20 05:21:03 +00:00
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
// UnsafeNewQMutex constructs the type using only unsafe pointers.
|
|
|
|
func UnsafeNewQMutex(h unsafe.Pointer, h_QBasicMutex unsafe.Pointer) *QMutex {
|
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &QMutex{h: (*C.QMutex)(h),
|
|
|
|
QBasicMutex: UnsafeNewQBasicMutex(h_QBasicMutex)}
|
2024-10-20 05:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewQMutex constructs a new QMutex object.
|
|
|
|
func NewQMutex() *QMutex {
|
2024-11-19 06:29:06 +00:00
|
|
|
var outptr_QMutex *C.QMutex = nil
|
|
|
|
var outptr_QBasicMutex *C.QBasicMutex = nil
|
|
|
|
|
|
|
|
C.QMutex_new(&outptr_QMutex, &outptr_QBasicMutex)
|
|
|
|
ret := newQMutex(outptr_QMutex, outptr_QBasicMutex)
|
|
|
|
ret.isSubclass = true
|
|
|
|
return ret
|
2024-10-20 05:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMutex) TryLock() bool {
|
|
|
|
return (bool)(C.QMutex_TryLock(this.h))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMutex) TryLockWithTimeout(timeout int) bool {
|
|
|
|
return (bool)(C.QMutex_TryLockWithTimeout(this.h, (C.int)(timeout)))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete this object from C++ memory.
|
|
|
|
func (this *QMutex) Delete() {
|
2024-11-19 06:29:06 +00:00
|
|
|
C.QMutex_Delete(this.h, C.bool(this.isSubclass))
|
2024-10-20 05:21:03 +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 *QMutex) GoGC() {
|
|
|
|
runtime.SetFinalizer(this, func(this *QMutex) {
|
|
|
|
this.Delete()
|
|
|
|
runtime.KeepAlive(this.h)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
type QRecursiveMutex struct {
|
2024-11-19 06:29:06 +00:00
|
|
|
h *C.QRecursiveMutex
|
|
|
|
isSubclass bool
|
2024-10-20 05:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QRecursiveMutex) cPointer() *C.QRecursiveMutex {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QRecursiveMutex) UnsafePointer() unsafe.Pointer {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return unsafe.Pointer(this.h)
|
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
// newQRecursiveMutex constructs the type using only CGO pointers.
|
2024-10-20 05:21:03 +00:00
|
|
|
func newQRecursiveMutex(h *C.QRecursiveMutex) *QRecursiveMutex {
|
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return &QRecursiveMutex{h: h}
|
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
// UnsafeNewQRecursiveMutex constructs the type using only unsafe pointers.
|
2024-10-20 05:21:03 +00:00
|
|
|
func UnsafeNewQRecursiveMutex(h unsafe.Pointer) *QRecursiveMutex {
|
2024-11-19 06:29:06 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &QRecursiveMutex{h: (*C.QRecursiveMutex)(h)}
|
2024-10-20 05:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewQRecursiveMutex constructs a new QRecursiveMutex object.
|
|
|
|
func NewQRecursiveMutex() *QRecursiveMutex {
|
2024-11-19 06:29:06 +00:00
|
|
|
var outptr_QRecursiveMutex *C.QRecursiveMutex = nil
|
|
|
|
|
|
|
|
C.QRecursiveMutex_new(&outptr_QRecursiveMutex)
|
|
|
|
ret := newQRecursiveMutex(outptr_QRecursiveMutex)
|
|
|
|
ret.isSubclass = true
|
|
|
|
return ret
|
2024-10-20 05:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QRecursiveMutex) Lock() {
|
|
|
|
C.QRecursiveMutex_Lock(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QRecursiveMutex) TryLock() bool {
|
|
|
|
return (bool)(C.QRecursiveMutex_TryLock(this.h))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QRecursiveMutex) Unlock() {
|
|
|
|
C.QRecursiveMutex_Unlock(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QRecursiveMutex) TryLock2() bool {
|
|
|
|
return (bool)(C.QRecursiveMutex_TryLock2(this.h))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QRecursiveMutex) TryLock1(timeout int) bool {
|
|
|
|
return (bool)(C.QRecursiveMutex_TryLock1(this.h, (C.int)(timeout)))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete this object from C++ memory.
|
|
|
|
func (this *QRecursiveMutex) Delete() {
|
2024-11-19 06:29:06 +00:00
|
|
|
C.QRecursiveMutex_Delete(this.h, C.bool(this.isSubclass))
|
2024-10-20 05:21:03 +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 *QRecursiveMutex) GoGC() {
|
|
|
|
runtime.SetFinalizer(this, func(this *QRecursiveMutex) {
|
|
|
|
this.Delete()
|
|
|
|
runtime.KeepAlive(this.h)
|
|
|
|
})
|
|
|
|
}
|