libs: wrap mutexes for build flag with godeadlock (#5126)

## Description

This PR wraps the stdlib sync.(RW)Mutex & godeadlock.(RW)Mutex. This enables using go-deadlock via a build flag instead of using sed to replace sync with godeadlock in all files

Closes: #3242
This commit is contained in:
Marko
2020-07-20 09:55:09 +02:00
committed by GitHub
parent 8cdb53c811
commit 2ac5a559b4
61 changed files with 182 additions and 145 deletions

View File

@@ -3,9 +3,9 @@ package events
import (
"fmt"
"sync"
"github.com/tendermint/tendermint/libs/service"
tmsync "github.com/tendermint/tendermint/libs/sync"
)
// ErrListenerWasRemoved is returned by AddEvent if the listener was removed.
@@ -54,7 +54,7 @@ type EventSwitch interface {
type eventSwitch struct {
service.BaseService
mtx sync.RWMutex
mtx tmsync.RWMutex
eventCells map[string]*eventCell
listeners map[string]*eventListener
}
@@ -162,7 +162,7 @@ func (evsw *eventSwitch) FireEvent(event string, data EventData) {
// eventCell handles keeping track of listener callbacks for a given event.
type eventCell struct {
mtx sync.RWMutex
mtx tmsync.RWMutex
listeners map[string]EventCallback
}
@@ -206,7 +206,7 @@ type EventCallback func(data EventData)
type eventListener struct {
id string
mtx sync.RWMutex
mtx tmsync.RWMutex
removed bool
events []string
}