runtime: fix map len and chan len/cap

This commit is contained in:
visualfc
2024-09-25 20:51:58 +08:00
parent 32f41a04ac
commit c184dc8d2f
7 changed files with 487 additions and 161 deletions

View File

@@ -53,6 +53,9 @@ func NewChan(eltSize, cap int) *Chan {
}
func ChanLen(p *Chan) (n int) {
if p == nil {
return 0
}
p.mutex.Lock()
n = p.len
p.mutex.Unlock()
@@ -60,6 +63,9 @@ func ChanLen(p *Chan) (n int) {
}
func ChanCap(p *Chan) int {
if p == nil {
return 0
}
return p.cap
}