Browse Source

Optimize http server of gnet (#5522)

Andy Pan 5 years ago
parent
commit
906134dea3
1 changed files with 5 additions and 0 deletions
  1. 5 0
      frameworks/Go/gnet/src/main.go

+ 5 - 0
frameworks/Go/gnet/src/main.go

@@ -4,6 +4,7 @@ import (
 	"flag"
 	"fmt"
 	"log"
+	"runtime"
 	"strconv"
 	"strings"
 	"time"
@@ -77,6 +78,10 @@ func (hs *httpServer) React(frame []byte, c gnet.Conn) (out []byte, action gnet.
 	return
 }
 
+func init() {
+	runtime.GOMAXPROCS(runtime.NumCPU() * 2)
+}
+
 func main() {
 	var port int
 	var multicore bool