Skip to content

Commit

Permalink
Optimize eventloop read/write and deprecate eviop
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Pan committed Sep 23, 2019
1 parent ff15523 commit b1ce4d4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ Source code in `gnet` is available under the MIT [License](/LICENSE).
- [evio](https://github.com/tidwall/evio)
- [go-disruptor](https://github.com/smartystreets-prototypes/go-disruptor)
- [ants](https://github.com/panjf2000/ants)
- [eviop](https://github.com/Allenxuxu/eviop)

# Relevant Articles

Expand Down
3 changes: 1 addition & 2 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,11 @@ Go Version : go version go1.12.9 darwin/amd64

`gnet` 的源码允许用户在遵循 MIT [开源证书](/LICENSE) 规则的前提下使用。

# 鸣谢
# 致谢

- [evio](https://github.com/tidwall/evio)
- [go-disruptor](https://github.com/smartystreets-prototypes/go-disruptor)
- [ants](https://github.com/panjf2000/ants)
- [eviop](https://github.com/Allenxuxu/eviop)

# 相关文章

Expand Down
16 changes: 3 additions & 13 deletions eventloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,26 +207,16 @@ func (l *loop) loopWrite(svr *server, conn *conn) error {
svr.events.PreWrite()
}

top, tail := conn.outBuf.PreReadAll()
n, err := unix.Write(conn.fd, top)
out := conn.outBuf.Bytes()
n, err := unix.Write(conn.fd, out)
if err != nil {
if err == unix.EAGAIN {
return nil
}
return l.loopCloseConn(svr, conn, err)
}
conn.outBuf.Advance(n)

if len(top) == n && len(tail) > 0 {
n, err := unix.Write(conn.fd, tail)
if err != nil {
if err == unix.EAGAIN {
return nil
}
return l.loopCloseConn(svr, conn, err)
}
conn.outBuf.Advance(n)
}
ringbuffer.Recycle(out)

if conn.outBuf.Length() == 0 {
l.poller.ModRead(conn.fd)
Expand Down

0 comments on commit b1ce4d4

Please sign in to comment.