Move mutex onto OutletFactory

It's bad form for the mutex to live in the global namespace when it
doesn't need to.
This commit is contained in:
Peter Waller
2014-05-21 07:54:07 +01:00
parent 4c61bb7cb7
commit 826329f426
+4 -4
View File
@@ -13,6 +13,8 @@ import (
type OutletFactory struct {
Outlets map[string]*Outlet
Padding int
sync.Mutex
}
type Outlet struct {
@@ -22,8 +24,6 @@ type Outlet struct {
Factory *OutletFactory
}
var mx sync.Mutex
var colors = []ct.Color{
ct.Cyan,
ct.Yellow,
@@ -68,8 +68,8 @@ func (of *OutletFactory) ErrorOutput(str string) {
// Write out a single coloured line
func (of *OutletFactory) WriteLine(left, right string, leftC, rightC ct.Color, isError bool) {
mx.Lock()
defer mx.Unlock()
of.Lock()
defer of.Unlock()
ct.ChangeColor(leftC, true, ct.None, false)
formatter := fmt.Sprintf("%%-%ds | ", of.Padding)