日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Go并發(fā)模式:管道和顯式取消

引言

Go并發(fā)原語使得構建流式數(shù)據(jù)管道,高效利用I/O和多核變得簡單。這篇文章介紹了幾個管道例子,重點指出在操作失敗時的細微差別,并介紹了優(yōu)雅處理失敗的技術。

什么是管道?

Go沒有正式的管道定義。管道只是眾多并發(fā)程序的一類。一般的,一個管道就是一些列的由channel連接起來的階段。每個階段都有執(zhí)行相同邏輯的goroutine。在每個階段中,goroutine

  • 從channel讀取上游數(shù)據(jù)
  • 在數(shù)據(jù)上執(zhí)行一些操作,通常會產(chǎn)生新的數(shù)據(jù)
  • 通過channel將數(shù)據(jù)發(fā)往下游

每個階段都可以有任意個輸入channel和輸出channel,除了第一個和最有一個channel(只有輸入channel或只有輸出channel)。第一個步驟通常叫數(shù)據(jù)源或者生產(chǎn)者,最后一個叫做存儲池或者消費者。

我們先從一個簡單的管道例子來解釋這些概念和技術,稍后我們會介紹一個更為復雜的例子。

數(shù)字的平方

假設管道有三個階段。

第一步,gen函數(shù),是一個將數(shù)字列表轉換到一個channel中的函數(shù)。Gen函數(shù)啟動了一個goroutine,將數(shù)字發(fā)送到channel,并在所有數(shù)字都發(fā)送完后關閉channel。

 
 
  1. func gen(nums ...int) <-chan int {
  2.     out := make(chan int)
  3.     go func() {
  4.         for _, n := range nums {
  5.             out <- n
  6.         }
  7.         close(out)
  8.     }()
  9.     return out
  10. }

第二個階段,sq,從上面的channel接收數(shù)字,并返回一個包含所有收到數(shù)字的平方的channel。在上游channel關閉后,這個階段已經(jīng)往下游發(fā)送完所有的結果,然后關閉輸出channel:

  
 
  1. func sq(in <-chan int) <-chan int {
  2.     out := make(chan int)
  3.     go func() {
  4.         for n := range in {
  5.             out <- n * n
  6.         }
  7.         close(out)
  8.     }()
  9.     return out
  10. }

main函數(shù)建立這個管道,并執(zhí)行第一個階段,從第二個階段接收結果并逐個打印,直到channel被關閉。

 
 
  1. func main() {
  2.     // Set up the pipeline.
  3.     c := gen(2, 3)
  4.     out := sq(c)
  5.  
  6.     // Consume the output.
  7.     fmt.Println(<-out) // 4
  8.     fmt.Println(<-out) // 9
  9. }

因為sq對輸入channel和輸出channel擁有相同的類型,我們可以任意次的組合他們。我們也可以像其他階段一樣,將main函數(shù)重寫成一個循環(huán)遍歷。

 
 
  1. func main() {
  2.     // Set up the pipeline and consume the output.
  3.     for n := range sq(sq(gen(2, 3))) {
  4.         fmt.Println(n) // 16 then 81
  5.     }
  6. }

扇出扇入(Fan-out, fan-in)

多個函數(shù)可以從同一個channel讀取數(shù)據(jù),直到這個channel關閉,這叫扇出。這是一種多個工作實例分布式地協(xié)作以并行利用CPU和I/O的方式。

一個函數(shù)可以從多個輸入讀取并處理數(shù)據(jù),直到所有的輸入channel都被關閉。這個函數(shù)會將所有輸入channel導入一個單一的channel。這個單一的channel在所有輸入channel都關閉后才會關閉。這叫做扇入。

我們可以設置我們的管道執(zhí)行兩個sq實例,每一個實例都從相同的輸入channel讀取數(shù)據(jù)。我們引入了一個新的函數(shù),merge,來扇入結果:

 
 
  1. func main() {
  2.     in := gen(2, 3)
  3.  
  4.     // Distribute the sq work across two goroutines that both read from in.
  5.     c1 := sq(in)
  6.     c2 := sq(in)
  7.  
  8.     // Consume the merged output from c1 and c2.
  9.     for n := range merge(c1, c2) {
  10.         fmt.Println(n) // 4 then 9, or 9 then 4
  11.     }
  12. }

merge函數(shù)為每一個輸入channel啟動一個goroutine,goroutine將數(shù)據(jù)拷貝到同一個輸出channel。這樣就將多個channel轉換成一個channel。一旦所有的output goroutine啟動起來,merge就啟動另一個goroutine,在所有輸入拷貝完畢后關閉輸出channel。
向一個關閉了的channel發(fā)送數(shù)據(jù)會觸發(fā)異常,所以在調(diào)用close之前確認所有的發(fā)送動作都執(zhí)行完畢很重要。sync.WaitGroup類型為這種同步提供了一種簡便的方法:

 
 
  1. func merge(cs ...<-chan int) <-chan int {
  2.     var wg sync.WaitGroup
  3.     out := make(chan int)
  4.  
  5.     // Start an output goroutine for each input channel in cs.  output
  6.     // copies values from c to out until c is closed, then calls wg.Done.
  7.     output := func(c <-chan int) {
  8.         for n := range c {
  9.             out <- n
  10.         }
  11.         wg.Done()
  12.     }
  13.     wg.Add(len(cs))
  14.     for _, c := range cs {
  15.         go output(c)
  16.     }
  17.  
  18.     // Start a goroutine to close out once all the output goroutines are
  19.     // done.  This must start after the wg.Add call.
  20.     go func() {
  21.         wg.Wait()
  22.         close(out)
  23.     }()
  24.     return out
  25. }

停止的藝術

我們所有的管道函數(shù)都遵循一種模式:

  • 發(fā)送者在發(fā)送完畢時關閉其輸出channel。
  • 接收者持續(xù)從輸入管道接收數(shù)據(jù)直到輸入管道關閉。

這種模式使得每一個接收函數(shù)都能寫成一個range循環(huán),保證所有的goroutine在數(shù)據(jù)成功發(fā)送到下游后就關閉。

但是在真實的案例中,并不是所有的輸入數(shù)據(jù)都需要被接收處理。有些時候是故意這么設計的:接收者可能只需要數(shù)據(jù)的子集就夠了;或者更一般的,因為輸入數(shù)據(jù)有錯誤而導致接收函數(shù)提早退出。上面任何一種情況下,接收者都不應該繼續(xù)等待后續(xù)的數(shù)據(jù)到來,并且我們希望上游函數(shù)停止生成后續(xù)步驟已經(jīng)不需要的數(shù)據(jù)。

在我們的管道例子中,如果一個階段無法消費所有的輸入數(shù)據(jù),那些發(fā)送這些數(shù)據(jù)的goroutine就會一直阻塞下去:

 
 
  1.     // Consume the first value from output.
  2.     out := merge(c1, c2)
  3.     fmt.Println(<-out) // 4 or 9
  4.     return
  5.     // Since we didn't receive the second value from out,
  6.     // one of the output goroutines is hung attempting to send it.
  7. }

這是一種資源泄漏:goroutine會占用內(nèi)存和運行時資源。goroutine棧持有的堆引用會阻止GC回收資源。而且goroutine不能被垃圾回收,必須主動退出。

我們必須重新設計管道中的上游函數(shù),在下游函數(shù)無法接收所有輸入數(shù)據(jù)時退出。一種方法就是讓輸出channel擁有一定的緩存。緩存可以存儲一定數(shù)量的數(shù)據(jù)。如果緩存空間足夠,發(fā)送操作就會馬上返回:

 
 
  1. c := make(chan int, 2) // buffer size 2
  2. c <- 1  // succeeds immediately
  3. c <- 2  // succeeds immediately
  4. c <- 3  // blocks until another goroutine does <-c and receives 1

如果在channel創(chuàng)建時就知道需要發(fā)送數(shù)據(jù)的數(shù)量,帶緩存的channel會簡化代碼。例如,我們可以重寫gen函數(shù),拷貝一系列的整數(shù)到一個帶緩存的channel而不是創(chuàng)建一個新的goroutine:

 
 
  1. func gen(nums ...int) <-chan int {
  2.     out := make(chan int, len(nums))
  3.     for _, n := range nums {
  4.         out <- n
  5.     }
  6.     close(out)
  7.     return out
  8. }

反過來我們看管道中被阻塞的goroutine,我們可以考慮為merge函數(shù)返回的輸出channel增加一個緩存:

 
 
  1. func merge(cs ...<-chan int) <-chan int {
  2.     var wg sync.WaitGroup
  3.     out := make(chan int, 1) // enough space for the unread inputs
  4.     // ... the rest is unchanged ...

雖然這樣可以避免了程序中goroutine的阻塞,但這是很爛的代碼。選擇緩存大小為1取決于知道m(xù)erge函數(shù)接收數(shù)字的數(shù)量和下游函數(shù)消費數(shù)字的數(shù)量。這是很不穩(wěn)定的:如果我們向gen多發(fā)送了一個數(shù)據(jù),或者下游函數(shù)少消費了數(shù)據(jù),我們就又一次阻塞了goroutine。

然而,我們需要提供一種方式,下游函數(shù)可以通知上游發(fā)送者下游要停止接收數(shù)據(jù)。

#p#

顯式取消

當main函數(shù)決定在沒有從out接收所有的數(shù)據(jù)而要退出時,它需要通知上游的goroutine取消即將發(fā)送的數(shù)據(jù)??梢酝ㄟ^向一個叫做done的channel發(fā)送數(shù)據(jù)來實現(xiàn)。因為有兩個潛在阻塞的goroutine,main函數(shù)會發(fā)送兩個數(shù)據(jù):

 
 
  1. func main() {
  2.     in := gen(2, 3)
  3.  
  4.     // Distribute the sq work across two goroutines that both read from in.
  5.     c1 := sq(in)
  6.     c2 := sq(in)
  7.  
  8.     // Consume the first value from output.
  9.     done := make(chan struct{}, 2)
  10.     out := merge(done, c1, c2)
  11.     fmt.Println(<-out) // 4 or 9
  12.  
  13.     // Tell the remaining senders we're leaving.
  14.     done <- struct{}{}
  15.     done <- struct{}{}
  16. }

對發(fā)送goroutine而言,需要將發(fā)送操作替換為一個select語句,要么out發(fā)生發(fā)送操作,要么從done接收數(shù)據(jù)。done的數(shù)據(jù)類型是空的struct,因為其值無關緊要:僅僅表示out需要取消發(fā)送操作。output 繼續(xù)在輸入channel循環(huán)執(zhí)行,因此上游函數(shù)是不會阻塞的。(接下來我們會討論如何讓循環(huán)提早退出)

 
 
  1. func merge(done <-chan struct{}, cs ...<-chan int) <-chan int {
  2.     var wg sync.WaitGroup
  3.     out := make(chan int)
  4.  
  5.     // Start an output goroutine for each input channel in cs.  output
  6.     // copies values from c to out until c is closed or it receives a value
  7.     // from done, then output calls wg.Done.
  8.     output := func(c <-chan int) {
  9.         for n := range c {
  10.             select {
  11.             case out <- n:
  12.             case <-done:
  13.             }
  14.         }
  15.         wg.Done()
  16.     }
  17.     // ... the rest is unchanged ...

這種方法有一個問題:每一個下游函數(shù)需要知道潛在可能阻塞的上游發(fā)送者的數(shù)量,以發(fā)送響應的信號讓其提早退出。跟蹤這些數(shù)量是無趣的而且很容易出錯。

我們需要一種能夠讓未知或無界數(shù)量的goroutine都能夠停止向下游發(fā)送數(shù)據(jù)的方法。在Go中,我們可以通過關閉一個channel實現(xiàn)。因為從一個關閉了的channel執(zhí)行接收操作總能馬上成功,并返回相應數(shù)據(jù)類型的零值。

這意味著main函數(shù)僅通過關閉done就能實現(xiàn)將所有的發(fā)送者解除阻塞。關閉操作是一個高效的對發(fā)送者的廣播信號。我們擴展管道中所有的函數(shù)接受done作為一個參數(shù),并通過defer來實現(xiàn)相應channel的關閉操作。因此,無論main函數(shù)在哪一行退出都會通知上游退出。

 
 
  1. func main() {
  2.     // Set up a done channel that's shared by the whole pipeline,
  3.     // and close that channel when this pipeline exits, as a signal
  4.     // for all the goroutines we started to exit.
  5.     done := make(chan struct{})
  6.     defer close(done)
  7.  
  8.     in := gen(done, 2, 3)
  9.  
  10.     // Distribute the sq work across two goroutines that both read from in.
  11.     c1 := sq(done, in)
  12.     c2 := sq(done, in)
  13.  
  14.     // Consume the first value from output.
  15.     out := merge(done, c1, c2)
  16.     fmt.Println(<-out) // 4 or 9
  17.  
  18.     // done will be closed by the deferred call.
  19. }

現(xiàn)在每一個管道函數(shù)在done被關閉后就可以馬上返回了。merge函數(shù)中的output可以在接收管道的數(shù)據(jù)消費完之前返回,因為output函數(shù)知道上游發(fā)送者sq會在done關閉后停止產(chǎn)生數(shù)據(jù)。同時,output通過defer語句保證wq.Done會在所有退出路徑上調(diào)用。

 
 
  1. func merge(done <-chan struct{}, cs ...<-chan int) <-chan int {
  2.     var wg sync.WaitGroup
  3.     out := make(chan int)
  4.  
  5.     // Start an output goroutine for each input channel in cs.  output
  6.     // copies values from c to out until c or done is closed, then calls
  7.     // wg.Done.
  8.     output := func(c <-chan int) {
  9.         defer wg.Done()
  10.         for n := range c {
  11.             select {
  12.             case out <- n:
  13.             case <-done:
  14.                 return
  15.             }
  16.         }
  17.     }
  18.     // ... the rest is unchanged ...

類似的,sq也可以在done關閉后馬上返回。sq通過defer語句使得任何退出路徑都能關閉其輸出channel out。

 
 
  1. func sq(done <-chan struct{}, in <-chan int) <-chan int {
  2.     out := make(chan int)
  3.     go func() {
  4.         defer close(out)
  5.         for n := range in {
  6.             select {
  7.             case out <- n * n:
  8.             case <-done:
  9.                 return
  10.             }
  11.         }
  12.     }()
  13.     return out
  14. }

管道構建的指導思想如下:

  • 每一個階段在所有發(fā)送操作完成后關閉輸出channel。
  • 每一個階段持續(xù)從輸入channel接收數(shù)據(jù)直到輸入channel被關閉或者生產(chǎn)者被解除阻塞(譯者:生產(chǎn)者退出)。

管道解除生產(chǎn)者阻塞有兩種方法:要么保證有足夠的緩存空間存儲將要被生產(chǎn)的數(shù)據(jù),要么顯式的通知生產(chǎn)者消費者要取消接收數(shù)據(jù)。

樹形摘要

讓我們來看一個更為實際的管道。

MD5是一個信息摘要算法,對于文件校驗非常有用。命令行工具md5sum很有用,可以打印一系列文件的摘要值。

 
 
  1. % md5sum *.go
  2. d47c2bbc28298ca9befdfbc5d3aa4e65  bounded.go
  3. ee869afd31f83cbb2d10ee81b2b831dc  parallel.go
  4. b88175e65fdcbc01ac08aaf1fd9b5e96  serial.go

我們的例子程序和md5sum類似,但是接受一個單一的文件夾作為參數(shù),打印該文件夾下每一個普通文件的摘要值,并按路徑名稱排序。

 
 
  1. % go run serial.go .
  2. d47c2bbc28298ca9befdfbc5d3aa4e65  bounded.go
  3. ee869afd31f83cbb2d10ee81b2b831dc  parallel.go
  4. b88175e65fdcbc01ac08aaf1fd9b5e96  serial.go

我們程序的main函數(shù)調(diào)用一個工具函數(shù)MD5ALL,該函數(shù)返回一個從路徑名稱到摘要值的哈希表,然后排序并輸出結果:

 
 
  1. func main() {
  2.     // Calculate the MD5 sum of all files under the specified directory,
  3.     // then print the results sorted by path name.
  4.     m, err := MD5All(os.Args[1])
  5.     if err != nil {
  6.         fmt.Println(err)
  7.         return
  8.     }
  9.     var paths []string
  10.     for path := range m {
  11.         paths = append(paths, path)
  12.     }
  13.     sort.Strings(paths)
  14.     for _, path := range paths {
  15.         fmt.Printf("%x  %s\n", m[path], path)
  16.     }
  17. }

MD5ALL是我們討論的核心。在 serial.go中,沒有采用任何并發(fā),僅僅遍歷文件夾,讀取文件并求出摘要值。

 
 
  1. // MD5All reads all the files in the file tree rooted at root and returns a map
  2. // from file path to the MD5 sum of the file's contents.  If the directory walk
  3. // fails or any read operation fails, MD5All returns an error.
  4. func MD5All(root string) (map[string][md5.Size]byte, error) {
  5.     m := make(map[string][md5.Size]byte)
  6.     err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
  7.         if err != nil {
  8.             return err
  9.         }
  10.         if info.IsDir() {
  11.             return nil
  12.         }
  13.         data, err := ioutil.ReadFile(path)
  14.         if err != nil {
  15.             return err
  16.         }
  17.         m[path] = md5.Sum(data)
  18.         return nil
  19.     })
  20.     if err != nil {
  21.         return nil, err
  22.     }
  23.     return m, nil
  24. }

#p#

并行摘要求值

在parallel.go中,我們將MD5ALL分成兩階段的管道。第一個階段,sumFiles,遍歷文件夾,每個文件一個goroutine進行求摘要值,然后將結果發(fā)送一個數(shù)據(jù)類型為result的channel中:

 
 
  1. type result struct {
  2.     path string
  3.     sum  [md5.Size]byte
  4.     err  error
  5. }

sumFiles 返回兩個channel:一個用于生成結果,一個用于filepath.Walk返回錯誤。Walk函數(shù)為每一個普通文件啟動一個goroutine,然后檢查done,如果done被關閉,walk馬上就會退出。

 
 
  1. func sumFiles(done <-chan struct{}, root string) (<-chan result, <-chan error) {
  2.     // For each regular file, start a goroutine that sums the file and sends
  3.     // the result on c.  Send the result of the walk on errc.
  4.     c := make(chan result)
  5.     errc := make(chan error, 1)
  6.     go func() {
  7.         var wg sync.WaitGroup
  8.         err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
  9.             if err != nil {
  10.                 return err
  11.             }
  12.             if info.IsDir() {
  13.                 return nil
  14.             }
  15.             wg.Add(1)
  16.             go func() {
  17.                 data, err := ioutil.ReadFile(path)
  18.                 select {
  19.                 case c <- result{path, md5.Sum(data), err}:
  20.                 case <-done:
  21.                 }
  22.                 wg.Done()
  23.             }()
  24.             // Abort the walk if done is closed.
  25.             select {
  26.             case <-done:
  27.                 return errors.New("walk canceled")
  28.             default:
  29.                 return nil
  30.             }
  31.         })
  32.         // Walk has returned, so all calls to wg.Add are done.  Start a
  33.         // goroutine to close c once all the sends are done.
  34.         go func() {
  35.             wg.Wait()
  36.             close(c)
  37.         }()
  38.         // No select needed here, since errc is buffered.
  39.         errc <- err
  40.     }()
  41.     return c, errc
  42. }

MD5All 從c中接收摘要值。MD5All 在遇到錯誤時提前退出,通過defer關閉done。

 
 
  1. func MD5All(root string) (map[string][md5.Size]byte, error) {
  2.     // MD5All closes the done channel when it returns; it may do so before
  3.     // receiving all the values from c and errc.
  4.     done := make(chan struct{})
  5.     defer close(done)
  6.  
  7.     c, errc := sumFiles(done, root)
  8.  
  9.     m := make(map[string][md5.Size]byte)
  10.     for r := range c {
  11.         if r.err != nil {
  12.             return nil, r.err
  13.         }
  14.         m[r.path] = r.sum
  15.     }
  16.     if err := <-errc; err != nil {
  17.         return nil, err
  18.     }
  19.     return m, nil
  20. }

有界并行

parallel.go中實現(xiàn)的MD5ALL,對每一個文件啟動了一個goroutine。在一個包含大量大文件的文件夾中,這會導致超過機器可用內(nèi)存的內(nèi)存分配。(譯者注:即發(fā)生OOM)

我們可以通過限制讀取文件的并發(fā)度來避免這種情況發(fā)生。在bounded.go中,我們通過創(chuàng)建一定數(shù)量的goroutine讀取文件。現(xiàn)在我們的管道現(xiàn)在有三個階段:遍歷文件夾,讀取文件并計算摘要值,收集摘要值。

第一個階段,walkFiles,輸出文件夾中普通文件的文件路徑:

 
 
  1. func walkFiles(done <-chan struct{}, root string) (<-chan string, <-chan error) {
  2.     paths := make(chan string)
  3.     errc := make(chan error, 1)
  4.     go func() {
  5.         // Close the paths channel after Walk returns.
  6.         defer close(paths)
  7.         // No select needed for this send, since errc is buffered.
  8.         errc <- filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
  9.             if err != nil {
  10.                 return err
  11.             }
  12.             if info.IsDir() {
  13.                 return nil
  14.             }
  15.             select {
  16.             case paths <- path:
  17.             case <-done:
  18.                 return errors.New("walk canceled")
  19.             }
  20.             return nil
  21.         })
  22.     }()
  23.     return paths, errc
  24. }

中間的階段啟動一定數(shù)量的digester goroutine,從paths接收文件名稱,并向c發(fā)送result結構:

 
 
  1. func digester(done <-chan struct{}, paths <-chan string, c chan<- result) {
  2.     for path := range paths {
  3.         data, err := ioutil.ReadFile(path)
  4.         select {
  5.         case c <- result{path, md5.Sum(data), err}:
  6.         case <-done:
  7.             return
  8.         }
  9.     }
  10. }

和前一個例子不同,digester并不關閉其輸出channel,因為輸出channel是共享的,多個goroutine會向同一個channel發(fā)送數(shù)據(jù)。MD5All 會在所有的digesters 結束后關閉響應的channel。

 
 
  1. // Start a fixed number of goroutines to read and digest files.
  2. c := make(chan result)
  3. var wg sync.WaitGroup
  4. const numDigesters = 20
  5. wg.Add(numDigesters)
  6. for i := 0; i < numDigesters; i++ {
  7.     go func() {
  8.         digester(done, paths, c)
  9.         wg.Done()
  10.     }()
  11. }
  12. go func() {
  13.     wg.Wait()
  14.     close(c)
  15. }()

我們也可以讓每一個digester創(chuàng)建并返回自己的輸出channel,但如果這樣的話,我們需要額外的goroutine來扇入這些結果。
最后一個階段從c中接收所有的result數(shù)據(jù),并從errc中檢查錯誤。這種檢查不能在之前的階段做,因為在這之前,walkFiles 可能被阻塞不能往下游發(fā)送數(shù)據(jù):

 
 
  1.     m := make(map[string][md5.Size]byte)
  2.     for r := range c {
  3.         if r.err != nil {
  4.             return nil, r.err
  5.         }
  6.         m[r.path] = r.sum
  7.     }
  8.     // Check whether the Walk failed.
  9.     if err := <-errc; err != nil {
  10.         return nil, err
  11.     }
  12.     return m, nil
  13. }

結論

這篇文章介紹了如果用Go構建流式數(shù)據(jù)管道的技術。在這樣的管道中處理錯誤有點取巧,因為管道中每一個階段可能被阻塞不能往下游發(fā)送數(shù)據(jù),下游階段可能已經(jīng)不關心輸入數(shù)據(jù)。我們展示了關閉channel如何向所有管道啟動的goroutine廣播一個done信號,并且定義了正確構建管道的指導思想。

深入閱讀:

? Go并發(fā)模式(視頻)展示了Go并發(fā)原語的基本概念和幾個實現(xiàn)的方法

? 高級Go并發(fā)模式(視頻)包含幾個更為復雜的Go并發(fā)原語的使用,尤其是select

? Douglas McIlroy的Squinting at Power Series論文展示了類似Go的并發(fā)模式如何為復雜的計算提供優(yōu)雅的支持。


本文名稱:Go并發(fā)模式:管道和顯式取消
URL鏈接:http://www.5511xx.com/article/cojihge.html