()
| 77 | } |
| 78 | |
| 79 | func main() { |
| 80 | runtime.GOMAXPROCS(runtime.NumCPU()) |
| 81 | |
| 82 | var corpus = make(map[string]struct{}) |
| 83 | var corpusMutex sync.Mutex |
| 84 | |
| 85 | numWorkers := runtime.NumCPU() |
| 86 | var wg sync.WaitGroup |
| 87 | wg.Add(numWorkers) |
| 88 | |
| 89 | for i := 0; i < numWorkers; i++ { |
| 90 | go func(workerID int) { |
| 91 | defer func() { |
| 92 | if r := recover(); r != nil { |
| 93 | fmt.Printf("Worker %d recovered from panic: %v\n", workerID, r) |
| 94 | debug.PrintStack() |
| 95 | } |
| 96 | }() |
| 97 | |
| 98 | defer wg.Done() |
| 99 | for { |
| 100 | var code string |
| 101 | |
| 102 | code = node(oneOf(list[int]{ |
| 103 | {3, 100}, |
| 104 | {4, 40}, |
| 105 | {5, 50}, |
| 106 | {6, 30}, |
| 107 | {7, 20}, |
| 108 | {8, 10}, |
| 109 | {9, 5}, |
| 110 | {10, 5}, |
| 111 | })) |
| 112 | |
| 113 | program, err := expr.Compile(code, expr.Env(Env)) |
| 114 | if err != nil { |
| 115 | continue |
| 116 | } |
| 117 | _, err = expr.Run(program, Env) |
| 118 | if err != nil { |
| 119 | continue |
| 120 | } |
| 121 | |
| 122 | corpusMutex.Lock() |
| 123 | if _, exists := corpus[code]; exists { |
| 124 | corpusMutex.Unlock() |
| 125 | continue |
| 126 | } |
| 127 | corpus[code] = struct{}{} |
| 128 | corpusMutex.Unlock() |
| 129 | |
| 130 | fmt.Println(code) |
| 131 | } |
| 132 | }(i) |
| 133 | } |
| 134 | |
| 135 | wg.Wait() |
| 136 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…