タグ

concurrencyに関するimiwonのブックマーク (8)

  • Go言語の並行処理デザインパターン by Rob Pike 後編 - Qiita

    前編の続きです。 前回のデザパタを、Google検索を例に適用しましょうという話。 Google 1.0 まずは並行処理が入っていない、そのまま逐次処理の例です。 ダミーの検索関数type Search func(query string) Resultを返す、fakeSearch関数を作っておきます。 ダミーの検索関数Searchは、time.Sleepで一定時間スリープして、検索しているフリをします。 package fake import ( "fmt" "math/rand" "time" ) var ( Web = fakeSearch("web") Image = fakeSearch("image") Video = fakeSearch("video") ) type Search func(query string) Result func fakeSearch(kind

    Go言語の並行処理デザインパターン by Rob Pike 後編 - Qiita
  • Go言語の並行処理デザインパターン by Rob Pike 前編 - Qiita

    少し古いですが、Rob Pikeの並行処理デザインパターンのビデオで取り上げられたコードまとめです。 オリジナルのソースコードはこちらで見れます。 Generator ジェネレータ package main import ( "fmt" "math/rand" "time" "runtime" ) func main() { runtime.GOMAXPROCS(runtime.NumCPU()) rand.Seed(time.Now().UnixNano()) c := boring("boring!") // Function returning a channel. for i := 0; i < 5; i++ { fmt.Printf("You say: %q\n", <-c) } fmt.Println("You're boring: I'm leaving.") } func

    Go言語の並行処理デザインパターン by Rob Pike 前編 - Qiita
  • Go 言語における並行処理の構築部材 - 詩と創作・思索のひろば

    5年前に買った『Java並行処理プログラミング ―その「基盤」と「最新API」を究める―』をようやく読んだ。買った頃には Perl やシンプルな JavaScript ばかり書いていたので並行プログラミングなんてほとんど気にすることがなく、実感がなくて読むのも途中で止まってしまっていたで、家を掃除しているときに見つけたもの。その後も趣味Android アプリを書くなど Java に触れる機会はあったけれど、せいぜいが AsyncTask を使うくらいで、マルチスレッドを強く意識してコードを書くこともなかった。 Java並行処理プログラミング ―その「基盤」と「最新API」を究める― 作者: Brian Goetz,Joshua Bloch,Doug Lea出版社/メーカー: ソフトバンククリエイティブ発売日: 2006/11/22メディア: 単行購入: 30人 クリック: 442回

    Go 言語における並行処理の構築部材 - 詩と創作・思索のひろば
  • Golang Channels Tutorial

    December 6, 2013 Golang has built-in instruments for writing concurrent programs. Placing a go statement before a function call starts the execution of that function as an independent concurrent thread in the same address space as the calling code. Such thread is called goroutine in Golang. Here I should mention that concurrently doesn’t always mean in parallel. Goroutines are means of creating co

  • The Nature Of Channels In Go

    Introduction In my last post called Concurrency, Goroutines and GOMAXPROCS, I set the stage for talking about channels. We discussed what concurrency was and how goroutines played a role. With that foundation in hand, we can now understand the nature of channels and how they can be used to synchronize goroutines to share resources in a safe, less error prone and fun way. What Are Channels Channels

    The Nature Of Channels In Go
    imiwon
    imiwon 2016/05/02
    チャンネル、ゴルーチン、ロックの例を図解しており、わかりやすい
  • Go の並行処理 - Block Rockin’ Codes

    intro 先日の Go のカンファレンス GoCon で、 Go の並行処理周りについて発表させて頂きました。 Go Conference 2013 spring - connpass 具体的には Goroutine や Channel の話ですが、これらの機能は結構面白くて、いじって遊んでるだけでもわくわくします。 Go の並行処理は、設計方針がわりと特殊だと思うのですが、設計がシンプルなので分かるとそこまで難しくはないです。 (使いこなすのは、経験が必要そうですが) 今回話すにあたって色々調べましたが、発表時間の都合上省いたものもあるし、質疑応答で聞かれて応えられなかったこともあるので、 ここでまとめて置こうと思います。 発表資料 今回の発表資料はこちらです。 このブログの内容は、これをベースにします。 http://jxck.node-ninja.com/slides/gocon-

    Go の並行処理 - Block Rockin’ Codes
  • Go言語の並行性を映像化する | POSTD

    Goというプログラミング言語の強みの1つは、 Tony Hoare考案のCSP に基づくビルトインの並行性(Concurrency)です。Goは並行性を念頭にデザインされているため、複雑に並行したパイプラインの構築を可能にしています。でも、それぞれの並行性パターンがどのように見えるものなのか気になったことはありませんか。 もちろん、気になったことはあると思います。恐らくそれぞれ形は違っても、誰もが頭に描いているのではないでしょうか。もし、「1から100までの数字」について聞かれたら、無意識に頭の中で数字のイメージを思い浮かべると思います。例えば、私の場合、自分の前から1から20までがまっすぐに並び、21以降は90度右に曲がり1000以降まで続くイメージが浮かびます。これは多分私が幼稚園の時に教室の壁に沿って数字が貼られていて、ちょうど角に数字の20があったからなのだと思います。別の例えをす

    Go言語の並行性を映像化する | POSTD
  • GitHub - jhalterman/concurrentunit: Toolkit for testing multi-threaded and asynchronous applications

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

    GitHub - jhalterman/concurrentunit: Toolkit for testing multi-threaded and asynchronous applications
  • 1