Created
September 26, 2013 19:47
-
-
Save chuckha/6719563 to your computer and use it in GitHub Desktop.
Code for a blog post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func GenerateAllPics() { | |
// Set the number of processors Go can use | |
runtime.GOMAXPROCS(runtime.NumCPU()) | |
// Make all the channels we need | |
rows := make(chan []string) | |
throttle := make(chan struct{}, 10) | |
doneChan := make(chan int) | |
// Start reading the CSV | |
go MustReadRowAtATime("data/training.csv", rows) | |
// Populate the throttle so that the workers can start working | |
go Populate(throttle) | |
// The goroutine that spawns workers that write images | |
go SpawnJobs(rows, doneChan, throttle) | |
// Block the main thread | |
for _ = range doneChan {} | |
fmt.Println("Done!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment