mts: nonembeded mutex in TimeLocation

This commit is contained in:
saxon 2019-01-10 17:26:48 +10:30
parent 304d5501ac
commit 7fe8356b11
1 changed files with 13 additions and 11 deletions

View File

@ -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