mirror of https://github.com/cjbassi/gotop.git
Fix race condition panic
This commit is contained in:
parent
43d8b32230
commit
ff62b55133
|
@ -3,6 +3,7 @@ package termui
|
|||
import (
|
||||
"image"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
. "github.com/gizak/termui"
|
||||
)
|
||||
|
@ -11,6 +12,8 @@ import (
|
|||
type Table struct {
|
||||
*Block
|
||||
|
||||
sync.Mutex
|
||||
|
||||
Header []string
|
||||
Rows [][]string
|
||||
|
||||
|
@ -49,6 +52,8 @@ func (self *Table) ColResize() {
|
|||
|
||||
// Buffer implements the Bufferer interface.
|
||||
func (self *Table) Draw(buf *Buffer) {
|
||||
self.Lock()
|
||||
|
||||
self.Block.Draw(buf)
|
||||
|
||||
self.ColResizer()
|
||||
|
@ -124,6 +129,7 @@ func (self *Table) Draw(buf *Buffer) {
|
|||
)
|
||||
}
|
||||
}
|
||||
self.Unlock()
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -66,7 +66,9 @@ func NewProc() *Proc {
|
|||
go func() {
|
||||
ticker := time.NewTicker(self.interval)
|
||||
for range ticker.C {
|
||||
self.Lock()
|
||||
self.update()
|
||||
self.Unlock()
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
Loading…
Reference in New Issue