示例#1
0
文件: impc.go 项目: CaptainSoOmA/Uni
func NewC() *ImpC {
	//
	x := new(ImpC)
	x.m = make(chan int, 1)
	x.m <- 0
	x.okL, x.okR = cond.New(&x.m), cond.New(&x.m)
	return x
}
示例#2
0
文件: impc.go 项目: CaptainSoOmA/Uni
func NewC(n uint) *ImpC {
	//
	if n < 2 {
		return nil
	}
	x := new(ImpC)
	x.involved = n
	x.m = make(chan int, 1)
	x.m <- 0
	x.Imp = cond.New(&x.m)
	return x
}
示例#3
0
文件: lockc.go 项目: CaptainSoOmA/Uni
func NewLockC() *LockC {
	//
	x := new(LockC)
	x.nForks = make([]uint, nPhilos)
	x.m = make(chan int, 1)
	x.m <- 0
	x.c = make([]cond.Condition, nPhilos)
	for p := uint(0); p < nPhilos; p++ {
		x.nForks[p] = 2
		x.c[p] = cond.New(&x.m)
	}
	return x
}