随笔- 452
文章- 302
评论- 28
阅读-
64万
04 2022 档案
gobing并行编程3-sync
摘要:传统的线程模型(通常在编写 Java、C++ 和Python 程序时使用)程序员在线程之间通信需要使用共享内存。通常,共享数据结构由锁保护,线程将争用这些锁来访问数据。 在某些情况下,通过使用线程安全的数据结构(如 Python 的Queue),这会变得更容易。 Go 的并发原语 goroutine
阅读全文
Go Concurrency Patterns: Pipelines and cancellation
摘要:Sameer Ajmani13 March 2014 Introduction Go’s concurrency primitives make it easy to construct streaming data pipelines that make efficient use of I/O
阅读全文
Go Concurrency Patterns: Timing out, moving on
摘要:Andrew Gerrand23 September 2010 Concurrent programming has its own idioms. A good example is timeouts. Although Go’s channels do not support them dire
阅读全文
golang 详解协程——errgroup
摘要:我们把一个复杂的任务,尤其是依赖多个微服务 rpc 需要聚合数据的任务,分解为依赖和并行,依赖的意思为: 需要上游 a 的数据才能访问下游 b 的数据进行组合。但是并行的意思为: 分解为多个小任务并行执行,最终等全部执行完毕。 https://pkg.go.dev/golang.org/x/sync
阅读全文