-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (33 loc) · 890 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
//"fmt"
"math/rand"
"time"
"./graph"
"os"
"strconv"
)
func main() {
t := int64(time.Now().Unix())
//t := int64(1510681144)
//fmt.Println("Seed:", t)
rand.Seed(t)
NProc, _ := strconv.Atoi(os.Args[1])
BasePort, _ := strconv.Atoi(os.Args[2])
MinDegree, _ := strconv.Atoi(os.Args[3])
MaxDegree, _ := strconv.Atoi(os.Args[4])
BaseTtl, _ := strconv.Atoi(os.Args[5])
quitCh := make(chan struct{})
killCh := make(chan struct{}, NProc)
gr := graph.Generate(NProc, MinDegree, MaxDegree, BasePort)
//fmt.Println(gr)
go proc(0, gr, quitCh, killCh, BaseTtl, true)
for i := 1; i < NProc; i++ {
go proc(i, gr, quitCh, killCh, BaseTtl, false)
}
<-quitCh
for i := 0; i < NProc; i++ {
killCh <- struct{}{}
}
time.Sleep(time.Millisecond * 100)
}