main is the entry point for the application
()
| 62 | |
| 63 | // main is the entry point for the application |
| 64 | func main() { |
| 65 | log.Println("Starting Process") |
| 66 | |
| 67 | // Create a new readerWriter with a max of 3 reads at a time |
| 68 | // and a total of 6 reader goroutines. |
| 69 | first := start("First", 3, 6) |
| 70 | |
| 71 | // Create a new readerWriter with a max of 1 reads at a time |
| 72 | // and a total of 1 reader goroutines. |
| 73 | second := start("Second", 2, 2) |
| 74 | |
| 75 | // Let the program run for 2 seconds. |
| 76 | time.Sleep(2 * time.Second) |
| 77 | |
| 78 | // Shutdown both of the readerWriter processes. |
| 79 | shutdown(first, second) |
| 80 | |
| 81 | log.Println("Process Ended") |
| 82 | return |
| 83 | } |
| 84 | |
| 85 | // start uses the generator pattern to create the readerWriter value. It launches |
| 86 | // goroutines to process the work, returning the created ReaderWriter value. |