Created
April 30, 2020 18:05
-
-
Save jasonkeene/0b0507c354b7cc08f80bfe163307b4a6 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
type ExportedType struct { | |
unguarded int | |
// iternal state that is subject to concurrent access and requires locking | |
protected struct { | |
sync.RWMutex | |
guarded1 int | |
guarded2 int | |
guarded3 int | |
} | |
} | |
func (e *ExportedType) Method() { | |
e.protected.Lock() | |
defer e.protected.Unlock() | |
// monkey with e.protected | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment