mirror of
https://codeberg.org/frosty/modbot.git
synced 2024-09-19 03:36:35 -04:00
remove mutex to potentially improve performance and fix deadlocks
This commit is contained in:
parent
633a3a7e6b
commit
d87187f61b
7
main.go
7
main.go
|
@ -26,7 +26,6 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
|
@ -37,7 +36,6 @@ import (
|
|||
var (
|
||||
updateChan = make(chan int)
|
||||
moduleOutputs = make([][]byte, len(modules))
|
||||
mutex sync.Mutex
|
||||
|
||||
sigChan = make(chan os.Signal, 1024)
|
||||
signalMap = make(map[os.Signal][]*Module)
|
||||
|
@ -91,10 +89,8 @@ func (m *Module) Run() {
|
|||
}
|
||||
}
|
||||
|
||||
mutex.Lock()
|
||||
moduleOutputs[m.pos] = output.Bytes()
|
||||
updateChan <- 1
|
||||
mutex.Unlock()
|
||||
}
|
||||
|
||||
func (m *Module) Init(pos int) {
|
||||
|
@ -153,11 +149,8 @@ func monitorUpdates(setXRootName bool) {
|
|||
var combinedOutput bytes.Buffer
|
||||
|
||||
for range updateChan {
|
||||
mutex.Lock()
|
||||
combinedOutput.Reset()
|
||||
createOutput(&combinedOutput)
|
||||
mutex.Unlock()
|
||||
|
||||
combinedOutputBytes := combinedOutput.Bytes()
|
||||
|
||||
if !bytes.Equal(combinedOutputBytes, lastOutput) {
|
||||
|
|
Loading…
Reference in a new issue