Skip to content

Instantly share code, notes, and snippets.

@tyler-smith
Last active November 5, 2019 03:13
Show Gist options
  • Save tyler-smith/691ebccd2a5044e0e6c483fdf38ab5a0 to your computer and use it in GitHub Desktop.
Save tyler-smith/691ebccd2a5044e0e6c483fdf38ab5a0 to your computer and use it in GitHub Desktop.
// Before
type utxoCache struct {
// ...
mtx sync.Mutex
}
// After
import "github.com/gcash/bchutil"
type utxoCache struct {
// ...
mtx bchutil.Mutex
}
// +build !mutex-logging
type LoggingMutex struct{
Name string // Not used, just for type compatility
sync.Mutex
}
// +build mutex-logging
import "github.com/gcash/bchlog"
type LoggingMutex struct{
Name string
log
sync.Mutex
}
func (m *LoggingMutex) Lock() {
bchlog.Debug("Locking mutex:", m.Name)
m.Mutex.Lock()
}
func (m *LoggingMutex) Unlock() {
bchlog.Debug("Unlocking mutex:", m.Name)
m.Mutex.Unlock()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment