Rename lock to mu. (#16)

Rename lock to mu everywhere.
pull/1/head
M-A 10 years ago committed by GitHub
parent aa5269b72f
commit 5fce5c83f9

@ -23,7 +23,8 @@ import (
type Conn struct {
w net.Conn
c chan ir.Message
lock sync.Mutex
mu sync.Mutex
list map[string][]string // list of remotes and associated keys
pendingList map[string][]string // list of remotes and associated keys being created.
}
@ -66,8 +67,8 @@ func (c *Conn) Channel() <-chan ir.Message {
//
// Empty if the list was not retrieved yet.
func (c *Conn) Codes() map[string][]string {
c.lock.Lock()
defer c.lock.Unlock()
c.mu.Lock()
defer c.mu.Unlock()
return c.list
}
@ -176,10 +177,10 @@ func (c *Conn) readData(r *bufio.Reader) error {
}
}
if all {
c.lock.Lock()
c.mu.Lock()
c.list = c.pendingList
c.pendingList = nil
c.lock.Unlock()
c.mu.Unlock()
}
}
default:

@ -25,7 +25,7 @@ const SkipAddr uint16 = 0xFFFF
// I2C represents an I²C master implemented as bit-banging on 2 GPIO pins.
type I2C struct {
lock sync.Mutex
mu sync.Mutex
scl gpio.PinIO // Clock line
sda gpio.PinIO // Data line
halfCycle time.Duration
@ -42,8 +42,8 @@ func (i *I2C) Close() error {
// Tx implements i2c.Conn.
func (i *I2C) Tx(addr uint16, w, r []byte) error {
i.lock.Lock()
defer i.lock.Unlock()
i.mu.Lock()
defer i.mu.Unlock()
runtime.LockOSThread()
defer runtime.UnlockOSThread()
//syscall.Setpriority(which, who, prio)
@ -90,8 +90,8 @@ func (i *I2C) Tx(addr uint16, w, r []byte) error {
// Speed implements i2c.Conn.
func (i *I2C) Speed(hz int64) error {
i.lock.Lock()
defer i.lock.Unlock()
i.mu.Lock()
defer i.mu.Unlock()
i.halfCycle = time.Second / time.Duration(hz) / time.Duration(2)
return nil
}

@ -28,7 +28,8 @@ type SPI struct {
sdi gpio.PinIn // MISO
sdo gpio.PinOut // MOSI
csn gpio.PinOut // CS
lock sync.Mutex
mu sync.Mutex
mode spi.Mode
bits int
halfCycle time.Duration
@ -45,16 +46,16 @@ func (s *SPI) Close() error {
// Speed implements spi.Conn.
func (s *SPI) Speed(hz int64) error {
s.lock.Lock()
defer s.lock.Unlock()
s.mu.Lock()
defer s.mu.Unlock()
s.halfCycle = time.Second / time.Duration(hz) / time.Duration(2)
return nil
}
// Configure implements spi.Conn.
func (s *SPI) Configure(mode spi.Mode, bits int) error {
s.lock.Lock()
defer s.lock.Unlock()
s.mu.Lock()
defer s.mu.Unlock()
if mode != spi.Mode3 {
return errors.New("not implemented")
}
@ -72,8 +73,8 @@ func (s *SPI) Tx(w, r []byte) error {
if len(r) != 0 && len(w) != len(r) {
return errors.New("write and read buffers must be the same length")
}
s.lock.Lock()
defer s.lock.Unlock()
s.mu.Lock()
defer s.mu.Unlock()
if s.csn != nil {
s.csn.Out(gpio.Low)
s.sleepHalfCycle()

Loading…
Cancel
Save