Created
December 16, 2019 06:48
-
-
Save Edison-Hsu/f6dd777bc8eca49ca638fe2dd19adb6e to your computer and use it in GitHub Desktop.
golang_work_queue_example
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 worker(jobChan <-chan Job) { | |
| for job := range jobChan { | |
| process(job) | |
| } | |
| } | |
| // make a channel with a capacity of 100. | |
| jobChan := make(chan Job, 100) | |
| // start the worker | |
| go worker(jobChan) | |
| // enqueue a job | |
| jobChan <- job |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment