Changed dispacher's sleep strategy in order to reduce cpu load
This commit is contained in:
parent
9061079361
commit
0becd1d9ac
|
@ -41,6 +41,7 @@ type Server struct {
|
|||
chUsers map[string]map[string]string
|
||||
chTopics map[string]string
|
||||
chModes map[string]map[string]bool
|
||||
|
||||
config *conf.ConfigFile
|
||||
configPath string
|
||||
|
||||
|
@ -62,6 +63,7 @@ func NewServer(configPath, software, version string) *Server {
|
|||
sv.delq = make(chan Client, 128)
|
||||
|
||||
sv.clients = make(map[string]Client)
|
||||
|
||||
sv.chUsers = make(map[string]map[string]string)
|
||||
sv.chTopics = make(map[string]string)
|
||||
sv.chModes = make(map[string]map[string]bool)
|
||||
|
@ -138,7 +140,6 @@ func (sv *Server) listenTls(laddr string) {
|
|||
|
||||
func (sv *Server) dispatcher() {
|
||||
for {
|
||||
time.Sleep(1 * time.Microsecond)
|
||||
sv.queueLen = float64(len(sv.queue))
|
||||
select {
|
||||
case msg := <-sv.queue:
|
||||
|
@ -178,6 +179,7 @@ func (sv *Server) dispatcher() {
|
|||
xlog.Info("Server has %d client(s)", len(sv.clients))
|
||||
xlog.Debug("Goroutines running: %d", runtime.NumGoroutine())
|
||||
default:
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue