Beispiel #1
0
func New(n uint, f FuncSpectrum /* , p PredSpectrum */) *Imp {
	//
	if n == 0 {
		return nil
	}
	x := new(Imp)
	x.nFns = n
	x.me = make(chan int, 1)
	x.me <- 0
	//  x.s = make ([]sync.Mutex, x.nFns)
	x.s = make([]chan int, x.nFns)
	for i := uint(0); i < x.nFns; i++ {
		//    x.s[i].Lock()
		x.s[i] = make(chan int, 1)
	}
	x.nB = make([]uint, x.nFns)
	//  x.urgent.Lock()
	x.urgent = make(chan int, 1)
	x.f = f
	//  if p == nil {
	x.p = TrueSp
	//  } else {
	//    x.cond = true
	//    x.p = p
	//  }
	x.pm = perm.New(x.nFns)
	return x
}
Beispiel #2
0
func New0(a Any, n uint, f FuncSpectrum, p PredSpectrum, s string, port uint) *Imp {
	//
	if n == 0 {
		Stop(pack, 1)
	}
	// if tst { println ("fmon.New0 started for host", h) }
	x := new(Imp)
	x.object = Clone(a)
	x.nFuncs = n
	x.ch = make([]*nchan.Imp, x.nFuncs)
	x.f, x.p, x.s = f, p, s
	x.serve0 = Null
	x.pm = perm.New(x.nFuncs)
	x.isServer = host.Local(s)
	for i := uint(0); i < x.nFuncs; i++ {
		x.ch[i] = nchan.New0(x.object, s, uint16(port+i), false)
		if x.ch[i].IsServer() != x.isServer {
			Stop(pack, 2)
		}
	}
	if tst {
		print("fmon.New0 ok for ")
		if x.isServer {
			print("server ")
		} else {
			print("client ")
		}
		println(s)
	}
	return x
}
Beispiel #3
0
func New(n uint, p PredSpectrum, e, l OpSpectrum) *Imp {
	//
	if n == 0 {
		return nil
	}
	x := new(Imp)
	x.nP = n
	x.s = make([]sem.Semaphore, x.nP)
	x.nB = make([]uint, x.nP)
	for k := uint(0); k < x.nP; k++ {
		x.s[k] = sem.NewGSel(0)
	}
	x.c, x.in, x.out = p, e, l
	x.p = perm.New(x.nP)
	return x
}
Beispiel #4
0
func New(n uint, c CondSpectrum, e, l OpSpectrum) *Imp {
	//
	if n == 0 {
		return nil
	}
	x := new(Imp)
	x.nP = n
	x.s = make([]sync.Mutex, x.nP)
	x.nB = make([]uint, x.nP)
	for k := uint(0); k < x.nP; k++ {
		x.s[k].Lock()
	}
	x.c, x.in, x.out = c, e, l
	x.p = perm.New(x.nP)
	return x
}