Skip to content

Commit d297082

Browse files
committed
update netpoll
1 parent 108b736 commit d297082

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

netpoll.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,21 @@ func netpollblock(pd *pollDesc, mode int32, waitio bool) bool {
477477
}
478478
```
479479

480+
gopark 会执行 netpollblockcommit,并将 gpp 挂起,netpollblockcommit 比较简单:
481+
482+
```go
483+
func netpollblockcommit(gp *g, gpp unsafe.Pointer) bool {
484+
r := atomic.Casuintptr((*uintptr)(gpp), pdWait, uintptr(unsafe.Pointer(gp)))
485+
if r {
486+
// Bump the count of goroutines waiting for the poller.
487+
// The scheduler uses this to decide whether to block
488+
// waiting for the poller if there is nothing else to do.
489+
atomic.Xadd(&netpollWaiters, 1)
490+
}
491+
return r
492+
}
493+
```
494+
480495
#### Write 流程
481496

482497
```go

0 commit comments

Comments
 (0)