mirror of
https://github.com/teivah/100-go-mistakes.git
synced 2026-06-21 00:47:11 +08:00
Lock minor change
This commit is contained in:
parent
d502acea3b
commit
6a199fc553
2 changed files with 4 additions and 4 deletions
|
|
@ -16,8 +16,8 @@ type Event struct {
|
|||
}
|
||||
|
||||
func (c *Cache) TrimOlderThan(since time.Duration) {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
t := time.Now().Add(-since)
|
||||
for i := 0; i < len(c.events); i++ {
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ type Event struct {
|
|||
}
|
||||
|
||||
func (c *Cache) TrimOlderThan(since time.Duration) {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
t := time.Now().Add(-since)
|
||||
for i := 0; i < len(c.events); i++ {
|
||||
|
|
|
|||
Loading…
Reference in a new issue