Skip to content

Commit

Permalink
fix: resolve the lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 committed Jun 28, 2021
1 parent 0de156b commit bb352e3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions eventloop_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ func (el *eventloop) loopTicker(ctx context.Context) {
switch action {
case None:
case Shutdown:
el.svr.logger.Debugf("stopping ticker in event-loop(%d) from Tick()", el.idx)
el.poller.Trigger(func() error {
err := el.poller.Trigger(func() error {
return gerrors.ErrServerShutdown
})
el.svr.logger.Debugf("stopping ticker in event-loop(%d) from Tick(), Trigger:%v", el.idx, err)
}
if timer == nil {
timer = time.NewTimer(delay)
Expand Down
19 changes: 0 additions & 19 deletions gnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ package gnet
import (
"context"
"net"
"runtime"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -332,21 +331,3 @@ func sniffErrorAndLog(err error) {
logging.DefaultLogger.Errorf(err.Error())
}
}

// channelBuffer determines whether the channel should be a buffered channel to get the best performance.
var channelBuffer = func() int {
// Use blocking channel if GOMAXPROCS=1.
// This switches context from sender to receiver immediately,
// which results in higher performance.
var n int
if n = runtime.GOMAXPROCS(0); n == 1 {
return 0
}

// Make channel non-blocking and set up its capacity with GOMAXPROCS if GOMAXPROCS>1,
// otherwise the sender might be dragged down if the receiver is CPU-bound.
//
// GOMAXPROCS determines how many goroutines can run in parallel,
// which makes it the best choice as the channel capacity,
return n
}()
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U=
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
18 changes: 18 additions & 0 deletions server_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,21 @@ func serve(eventHandler EventHandler, listener *listener, options *Options, prot

return
}

// channelBuffer determines whether the channel should be a buffered channel to get the best performance.
var channelBuffer = func() int {
// Use blocking channel if GOMAXPROCS=1.
// This switches context from sender to receiver immediately,
// which results in higher performance.
var n int
if n = runtime.GOMAXPROCS(0); n == 1 {
return 0
}

// Make channel non-blocking and set up its capacity with GOMAXPROCS if GOMAXPROCS>1,
// otherwise the sender might be dragged down if the receiver is CPU-bound.
//
// GOMAXPROCS determines how many goroutines can run in parallel,
// which makes it the best choice as the channel capacity,
return n
}()

0 comments on commit bb352e3

Please sign in to comment.