Last active
November 5, 2019 03:13
-
-
Save tyler-smith/691ebccd2a5044e0e6c483fdf38ab5a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Before | |
type utxoCache struct { | |
// ... | |
mtx sync.Mutex | |
} | |
// After | |
import "github.com/gcash/bchutil" | |
type utxoCache struct { | |
// ... | |
mtx bchutil.Mutex | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build !mutex-logging | |
type LoggingMutex struct{ | |
Name string // Not used, just for type compatility | |
sync.Mutex | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +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