Skip to content

Commit ffe023c

Browse files
committed
use RWMutex
1 parent ef995d4 commit ffe023c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

storage/operation/callbacks.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package operation
33
import "sync"
44

55
type Callbacks struct {
6-
sync.Mutex // protect callbacks
7-
callbacks []func(error)
6+
sync.RWMutex // protect callbacks
7+
callbacks []func(error)
88
}
99

1010
func (b *Callbacks) AddCallback(callback func(error)) {
@@ -15,8 +15,8 @@ func (b *Callbacks) AddCallback(callback func(error)) {
1515
}
1616

1717
func (b *Callbacks) NotifyCallbacks(err error) {
18-
b.Lock()
19-
defer b.Unlock()
18+
b.RLock()
19+
defer b.RUnlock()
2020

2121
for _, callback := range b.callbacks {
2222
callback(err)

0 commit comments

Comments
 (0)