【问题标题】:What does P mean in Go's sync.Pool source code?Go 的 sync.Pool 源代码中的 P 是什么意思?
【发布时间】:2018-08-26 04:48:39
【问题描述】:

最近,我一直在研究 Go 的源代码。当我查看sync.Pool的细节时,我发现了一个我无法理解的评论。

https://golang.org/src/sync/pool.go?s=1633:1992#L58

// Local per-P Pool appendix.
type poolLocalInternal struct {
    private interface{}   // Can be used only by the respective P.
    shared  []interface{} // Can be used by any P.
    Mutex                 // Protects shared.
}

本地 per-P 池附录。

per-P 是什么意思?

只能由各自的P使用

P 是什么意思?

【问题讨论】:

    标签: go


    【解决方案1】:

    P 代表处理器。处理器是用于执行 Go 代码的资源。一个进程中恰好有 GOMAXPROC Ps。 The Go Scheduler Design Doc 详细描述了 Ps。相关代码在runtime package

    【讨论】:

      猜你喜欢
      • 2013-06-06
      • 2012-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-09
      • 2015-11-03
      • 1970-01-01
      相关资源
      最近更新 更多