Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
lesismal committed Jan 19, 2024
1 parent 7c12895 commit 69dfa3c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ func main() {

### Different IOMod

| IOMod | Remarks |
| ---------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| IOModNonBlocking | There's no difference between this IOMod and the old version with no IOMod. All the connections will be handled by poller. |
| IOModBlocking | All the connections will be handled by at least one goroutine, for websocket, we can set Upgrader.BlockingModAsyncWrite=true to handle writting with a separated goroutine and then avoid Head-of-line blocking on broadcasting scenarios. |
| IOModMixed | We set the Engine.MaxBlockingOnline, if the online num is smaller than it, the new connection will be handled by single goroutine as IOModBlocking, else the new connection will be handled by poller. |
| IOMod | Remarks |
| ---------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| IOModNonBlocking | There's no difference between this IOMod and the old version with no IOMod. All the connections will be handled by poller. |
| IOModBlocking | All the connections will be handled by at least one goroutine, for websocket, we can set Upgrader.BlockingModAsyncWrite=true to handle writing with a separated goroutine and then avoid Head-of-line blocking on broadcasting scenarios. |
| IOModMixed | We set the Engine.MaxBlockingOnline, if the online num is smaller than it, the new connection will be handled by single goroutine as IOModBlocking, else the new connection will be handled by poller. |

The `IOModBlocking` aims to improve the performance for low online service, it runs faster than std.
The `IOModMixed` aims to keep a balance between performance and cpu/mem cost in different scenarios: when there are not too many online connections, it performs better than std, or else it can serve lots of online connections and keep healthy.
Expand Down
2 changes: 1 addition & 1 deletion conn_std.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (c *Conn) Writev(in [][]byte) (int, error) {
c.Close()
}
if c.p.g.onWrittenSize != nil && nwrite > 0 {
total := nwrite
total := int(nwrite)
for i := 0; total > 0; i++ {
if total <= len(in[i]) {
c.p.g.onWrittenSize(c, in[i][:total], total)
Expand Down
2 changes: 1 addition & 1 deletion engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (g *Engine) OnData(h func(c *Conn, data []byte)) {
}

// OnWrittenSize registers callback for written size.
// If len(b) is bigger than 0, it represents that it's writting a buffer,
// If len(b) is bigger than 0, it represents that it's writing a buffer,
// else it's operating by Sendfile.
func (g *Engine) OnWrittenSize(h func(c *Conn, b []byte, n int)) {
if h == nil {
Expand Down

0 comments on commit 69dfa3c

Please sign in to comment.