mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-03 23:20:25 +08:00
增加默认的并发读写线程数
This commit is contained in:
@@ -8,8 +8,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var maxThreads = runtime.NumCPU()
|
var maxThreads = runtime.NumCPU()
|
||||||
var WriterLimiter = NewLimiter(max(maxThreads, 8))
|
var WriterLimiter = NewLimiter(max(maxThreads*8, 16))
|
||||||
var ReaderLimiter = NewLimiter(max(maxThreads, 8))
|
var ReaderLimiter = NewLimiter(max(maxThreads*8, 16))
|
||||||
|
|
||||||
type Limiter struct {
|
type Limiter struct {
|
||||||
threads chan struct{}
|
threads chan struct{}
|
||||||
@@ -19,11 +19,11 @@ type Limiter struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewLimiter(threads int) *Limiter {
|
func NewLimiter(threads int) *Limiter {
|
||||||
if threads < 4 {
|
if threads < 16 {
|
||||||
threads = 4
|
threads = 16
|
||||||
}
|
}
|
||||||
if threads > 64 {
|
if threads > 1024 {
|
||||||
threads = 64
|
threads = 1024
|
||||||
}
|
}
|
||||||
|
|
||||||
var threadsChan = make(chan struct{}, threads)
|
var threadsChan = make(chan struct{}, threads)
|
||||||
|
|||||||
Reference in New Issue
Block a user