示例#1
0
文件: node.go 项目: rhino1998/cluster
func NewNode(extip, locip string, description info.Info, ttl time.Duration, maxtasks int) *Node {
	thispeer := peers.ThisPeer(locip, extip, description)
	return &Node{
		data:                 make(map[string][]byte),
		Peers:                peers.NewPeers(thispeer),
		Peer:                 *thispeer,
		lastroutetableupdate: time.Now(),
		TaskValue:            0,
		TTL:                  ttl,
		MaxTasks:             maxtasks,
		queuelock:            multimutex.NewMultiMutex(500),
		allocatelock:         multimutex.NewMultiMutex(500),
		processlock:          multimutex.NewMultiMutex(1),
		routelock:            multimutex.NewMultiMutex(500),
	}
}
示例#2
0
文件: test.go 项目: rhino1998/cluster
func main() {
	temp := &Temp{queue: multimutex.NewMultiMutex(5)}
	temp.printlock(1, 5*time.Second)
	temp.printlock(2, 5*time.Second)
	temp.printlock(3, 5*time.Second)
	temp.printlock(4, 6*time.Second)
	temp.printlock(5, 5*time.Second)
	temp.printlock(6, 3*time.Second)
	temp.printlock(7, 5*time.Second)
	temp.printlock(8, 2*time.Second)
	temp.printlock(9, 5*time.Second)
	temp.printlock(10, 7*time.Second)
	temp.printlock(11, 5*time.Second)
	select {}
}