MCPcopy Create free account
hub / github.com/goinaction/code / main

Function main

chapter7/patterns/semaphore/semaphore.go:64–83  ·  view source on GitHub ↗

main is the entry point for the application

()

Source from the content-addressed store, hash-verified

62
63// main is the entry point for the application
64func 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.

Callers

nothing calls this directly

Calls 2

startFunction · 0.85
shutdownFunction · 0.85

Tested by

no test coverage detected