Ejemplo n.º 1
0
// Remove deletes the semaphore set.
// This will also awake anyone blocked on the set with EIDRM.
func (ss *SemaphoreSet) Remove() error {
	rc, err := C.semctl_noarg(C.int(ss.id), 0, C.IPC_RMID)
	if rc == -1 {
		return err
	}
	return nil
}
Ejemplo n.º 2
0
// Getval retrieves the value of a single semaphore in the set
func (ss *SemaphoreSet) Getval(num uint16) (int, error) {
	val, err := C.semctl_noarg(C.int(ss.id), C.int(num), C.GETVAL)
	if val == -1 {
		return -1, err
	}
	return int(val), nil
}
Ejemplo n.º 3
0
// GetZCnt returns the # of those blocked on WaitZero on the num-th semaphore
func (ss *SemaphoreSet) GetZCnt(num uint16) (int, error) {
	rc, err := C.semctl_noarg(C.int(ss.id), C.int(num), C.GETZCNT)
	if rc == -1 {
		return 0, err
	}
	return int(rc), nil
}