mirror of https://bitbucket.org/ausocean/av.git
mts: nonembeded mutex in TimeLocation
This commit is contained in:
parent
304d5501ac
commit
7fe8356b11
|
@ -127,37 +127,39 @@ const (
|
|||
|
||||
// timeLocation holds time and location data
|
||||
type timeLocation struct {
|
||||
sync.RWMutex
|
||||
mu sync.RWMutex
|
||||
time uint64
|
||||
location string
|
||||
}
|
||||
|
||||
// SetTimeStamp sets the time field of a TimeLocation.
|
||||
func (tl *timeLocation) SetTimeStamp(t uint64) {
|
||||
tl.Lock()
|
||||
tl.mu.Lock()
|
||||
tl.time = t
|
||||
tl.Unlock()
|
||||
tl.mu.Unlock()
|
||||
}
|
||||
|
||||
// GetTimeStamp returns the location of a TimeLocation.
|
||||
func (tl *timeLocation) TimeStamp() uint64 {
|
||||
tl.RLock()
|
||||
defer tl.RUnlock()
|
||||
return tl.time
|
||||
tl.mu.RLock()
|
||||
t := tl.time
|
||||
tl.mu.RUnlock()
|
||||
return t
|
||||
}
|
||||
|
||||
// SetLocation sets the location of a TimeLocation.
|
||||
func (tl *timeLocation) SetLocation(l string) {
|
||||
tl.Lock()
|
||||
tl.mu.Lock()
|
||||
tl.location = l
|
||||
tl.Unlock()
|
||||
tl.mu.Unlock()
|
||||
}
|
||||
|
||||
// GetLocation returns the location of a TimeLocation.
|
||||
func (tl *timeLocation) Location() string {
|
||||
tl.RLock()
|
||||
defer tl.RUnlock()
|
||||
return tl.location
|
||||
tl.mu.RLock()
|
||||
l := tl.location
|
||||
tl.mu.RUnlock()
|
||||
return l
|
||||
}
|
||||
|
||||
// MetData will hold time and location data which may be set externally if
|
||||
|
|
Loading…
Reference in New Issue