Skip to content

Commit 75c8959

Browse files
committed
update netpoll
1 parent a770539 commit 75c8959

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

netpoll.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ func installTestHooks() {
3232
用这种全局函数 hook,或者叫注册表的方式,可以实现类似于面向对象中的 interface 功能。不过因为不同平台提供的网络编程函数差别有些大,所以这里这些全局网络函数也就只是用来方便测试。
3333

3434
```go
35-
// Integrated network poller (platform-independent part).
36-
// A particular implementation (epoll/kqueue) must define the following functions:
37-
// func netpollinit() // to initialize the poller
38-
// func netpollopen(fd uintptr, pd *pollDesc) int32 // to arm edge-triggered notifications
39-
// and associate fd with pd.
40-
// An implementation must call the following function to denote that the pd is ready.
35+
// 整体的 network poller(平台无关部分)
36+
// 具体的实现需要定义下面这些函数:
37+
// func netpollinit() // 初始化 poller
38+
// func netpollopen(fd uintptr, pd *pollDesc) int32 // 用来装备边缘触发的通知
39+
// 并且将 fd pd 做好关联
40+
// 具体实现中,必须调用 下面的函数来表示 pd 已经 ready
4141
// func netpollready(gpp **g, pd *pollDesc, mode int32)
4242

43-
// pollDesc contains 2 binary semaphores, rg and wg, to park reader and writer
44-
// goroutines respectively. The semaphore can be in the following states:
43+
// pollDesc 包含两个二元信号量, rg wg, 分别用来 park 读、写的 goroutine
44+
// 信号量可以是下面几种状态:
4545
// pdReady - io readiness notification is pending;
4646
// a goroutine consumes the notification by changing the state to nil.
4747
// pdWait - a goroutine prepares to park on the semaphore, but not yet parked;

0 commit comments

Comments
 (0)