Upgrade to Pro — share decks privately, control downloads, hide ads and more …

goroutineとマルチスレッドデザインパターン/ goroutine and multit...

nametake
December 08, 2016

goroutineとマルチスレッドデザインパターン/ goroutine and multithreaded design pattern

https://connpass.com/event/28621/
Go言語LT大会! 「最近、Go言語始めました」の会での発表資料

nametake

December 08, 2016
Tweet

More Decks by nametake

Other Decks in Programming

Transcript

  1. ϚϧνεϨου
 σβΠϯύλʔϯ • Single Thread Execution • Immutable • Guarded

    Suspension • Balking • Producer-Consumer • Read-Write Lock • Thread-Per-Message • Worker Thread • Future • Two-Phase Termination • Thread-Specific Storage • Active Object
  2. channelͰղܾ • Single Thread Execution • Immutable • Guarded Suspension

    • Balking • Producer-Consumer • Read-Write Lock • Thread-Per-Message • Worker Thread • Future • Two-Phase Termination • Thread-Specific Storage • Active Object
  3. selectͰղܾ • Single Thread Execution • Immutable • Guarded Suspension

    • Balking • Producer-Consumer • Read-Write Lock • Thread-Per-Message • Worker Thread • Future • Two-Phase Termination • Thread-Specific Storage • Active Object
  4. ύοέʔδͰղܾ • Single Thread Execution • Immutable • Guarded Suspension

    • Balking • Producer-Consumer • Read-Write Lock • Thread-Per-Message • Worker Thread • Future • Two-Phase Termination • Thread-Specific Storage • Active Object
  5. ϚϧνεϨου σβΠϯύλʔϯ • Single Thread Execution • Immutable • Guarded

    Suspension • Balking • Producer-Consumer • Read-Write Lock • Thread-Per-Message • Worker Thread • Future • Two-Phase Termination • Thread-Specific Storage • Active Object
  6. channelͩͱ؆୯ func heavy(queue <-chan string) { url := <-queue //

    ϦΫΤετॲཧ } func main() { queue := make(chan string, 32) for i := 0; i < 3; i++ { go heavy(queue) } queue <- “https://google.co.jp” queue <- “https://google.com” // লུ }