embed mutex

This commit is contained in:
Anantha Kumaran 2022-05-14 13:05:06 +05:30
parent bbc830a399
commit f7d38b3985
2 changed files with 6 additions and 6 deletions

View File

@ -11,7 +11,7 @@ import (
)
type interestCache struct {
mu sync.Mutex
sync.Mutex
loaded bool
postings map[time.Time][]posting.Posting
}
@ -19,8 +19,8 @@ type interestCache struct {
var icache interestCache
func loadInterestCache(db *gorm.DB) {
icache.mu.Lock()
defer icache.mu.Unlock()
icache.Lock()
defer icache.Unlock()
if icache.loaded {
return

View File

@ -14,7 +14,7 @@ import (
)
type priceCache struct {
mu sync.Mutex
sync.Mutex
loaded bool
pricesTree map[string]*btree.BTree
}
@ -22,8 +22,8 @@ type priceCache struct {
var pcache priceCache
func loadPriceCache(db *gorm.DB) {
pcache.mu.Lock()
defer pcache.mu.Unlock()
pcache.Lock()
defer pcache.Unlock()
if pcache.loaded {
return