2024-08-25 04:08:24 +00:00
|
|
|
package qt
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
#include "gen_qsystemsemaphore.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 QSystemSemaphore__AccessMode int
|
|
|
|
|
|
|
|
const (
|
2024-09-20 07:13:26 +00:00
|
|
|
QSystemSemaphore__Open QSystemSemaphore__AccessMode = 0
|
|
|
|
QSystemSemaphore__Create QSystemSemaphore__AccessMode = 1
|
2024-09-04 06:54:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type QSystemSemaphore__SystemSemaphoreError int
|
|
|
|
|
|
|
|
const (
|
2024-09-20 07:13:26 +00:00
|
|
|
QSystemSemaphore__NoError QSystemSemaphore__SystemSemaphoreError = 0
|
|
|
|
QSystemSemaphore__PermissionDenied QSystemSemaphore__SystemSemaphoreError = 1
|
|
|
|
QSystemSemaphore__KeyError QSystemSemaphore__SystemSemaphoreError = 2
|
|
|
|
QSystemSemaphore__AlreadyExists QSystemSemaphore__SystemSemaphoreError = 3
|
|
|
|
QSystemSemaphore__NotFound QSystemSemaphore__SystemSemaphoreError = 4
|
|
|
|
QSystemSemaphore__OutOfResources QSystemSemaphore__SystemSemaphoreError = 5
|
|
|
|
QSystemSemaphore__UnknownError QSystemSemaphore__SystemSemaphoreError = 6
|
2024-09-04 06:54:22 +00:00
|
|
|
)
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
type QSystemSemaphore struct {
|
|
|
|
h *C.QSystemSemaphore
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QSystemSemaphore) cPointer() *C.QSystemSemaphore {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
|
|
|
func newQSystemSemaphore(h *C.QSystemSemaphore) *QSystemSemaphore {
|
2024-09-01 02:23:55 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-08-25 04:08:24 +00:00
|
|
|
return &QSystemSemaphore{h: h}
|
|
|
|
}
|
|
|
|
|
|
|
|
func newQSystemSemaphore_U(h unsafe.Pointer) *QSystemSemaphore {
|
|
|
|
return newQSystemSemaphore((*C.QSystemSemaphore)(h))
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
// NewQSystemSemaphore constructs a new QSystemSemaphore object.
|
|
|
|
func NewQSystemSemaphore(key string) *QSystemSemaphore {
|
2024-09-14 22:29:05 +00:00
|
|
|
key_ms := miqt_strdupg(key)
|
|
|
|
defer C.free(key_ms)
|
|
|
|
ret := C.QSystemSemaphore_new((*C.struct_miqt_string)(key_ms))
|
2024-08-29 07:01:51 +00:00
|
|
|
return newQSystemSemaphore(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewQSystemSemaphore2 constructs a new QSystemSemaphore object.
|
|
|
|
func NewQSystemSemaphore2(key string, initialValue int) *QSystemSemaphore {
|
2024-09-14 22:29:05 +00:00
|
|
|
key_ms := miqt_strdupg(key)
|
|
|
|
defer C.free(key_ms)
|
|
|
|
ret := C.QSystemSemaphore_new2((*C.struct_miqt_string)(key_ms), (C.int)(initialValue))
|
2024-08-29 07:01:51 +00:00
|
|
|
return newQSystemSemaphore(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewQSystemSemaphore3 constructs a new QSystemSemaphore object.
|
2024-09-04 06:54:22 +00:00
|
|
|
func NewQSystemSemaphore3(key string, initialValue int, mode QSystemSemaphore__AccessMode) *QSystemSemaphore {
|
2024-09-14 22:29:05 +00:00
|
|
|
key_ms := miqt_strdupg(key)
|
|
|
|
defer C.free(key_ms)
|
2024-09-18 00:12:02 +00:00
|
|
|
ret := C.QSystemSemaphore_new3((*C.struct_miqt_string)(key_ms), (C.int)(initialValue), (C.int)(mode))
|
2024-08-29 07:01:51 +00:00
|
|
|
return newQSystemSemaphore(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QSystemSemaphore) SetKey(key string) {
|
2024-09-14 22:29:05 +00:00
|
|
|
key_ms := miqt_strdupg(key)
|
|
|
|
defer C.free(key_ms)
|
|
|
|
C.QSystemSemaphore_SetKey(this.h, (*C.struct_miqt_string)(key_ms))
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QSystemSemaphore) Key() string {
|
2024-09-14 22:29:05 +00:00
|
|
|
var _ms *C.struct_miqt_string = C.QSystemSemaphore_Key(this.h)
|
|
|
|
_ret := C.GoStringN(&_ms.data, C.int(int64(_ms.len)))
|
|
|
|
C.free(unsafe.Pointer(_ms))
|
|
|
|
return _ret
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QSystemSemaphore) Acquire() bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QSystemSemaphore_Acquire(this.h))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QSystemSemaphore) Release() bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QSystemSemaphore_Release(this.h))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
func (this *QSystemSemaphore) Error() QSystemSemaphore__SystemSemaphoreError {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (QSystemSemaphore__SystemSemaphoreError)(C.QSystemSemaphore_Error(this.h))
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QSystemSemaphore) ErrorString() string {
|
2024-09-14 22:29:05 +00:00
|
|
|
var _ms *C.struct_miqt_string = C.QSystemSemaphore_ErrorString(this.h)
|
|
|
|
_ret := C.GoStringN(&_ms.data, C.int(int64(_ms.len)))
|
|
|
|
C.free(unsafe.Pointer(_ms))
|
|
|
|
return _ret
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
func (this *QSystemSemaphore) SetKey2(key string, initialValue int) {
|
2024-09-14 22:29:05 +00:00
|
|
|
key_ms := miqt_strdupg(key)
|
|
|
|
defer C.free(key_ms)
|
|
|
|
C.QSystemSemaphore_SetKey2(this.h, (*C.struct_miqt_string)(key_ms), (C.int)(initialValue))
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
func (this *QSystemSemaphore) SetKey3(key string, initialValue int, mode QSystemSemaphore__AccessMode) {
|
2024-09-14 22:29:05 +00:00
|
|
|
key_ms := miqt_strdupg(key)
|
|
|
|
defer C.free(key_ms)
|
2024-09-18 00:12:02 +00:00
|
|
|
C.QSystemSemaphore_SetKey3(this.h, (*C.struct_miqt_string)(key_ms), (C.int)(initialValue), (C.int)(mode))
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QSystemSemaphore) Release1(n int) bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QSystemSemaphore_Release1(this.h, (C.int)(n)))
|
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 *QSystemSemaphore) Delete() {
|
|
|
|
C.QSystemSemaphore_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 *QSystemSemaphore) GoGC() {
|
|
|
|
runtime.SetFinalizer(this, func(this *QSystemSemaphore) {
|
|
|
|
this.Delete()
|
|
|
|
runtime.KeepAlive(this.h)
|
|
|
|
})
|
|
|
|
}
|