#Associating Locks with other Objects

6 messages · Page 1 of 1 (latest)

lyric wharf
#

Are there any patterns people use to pass around objects and the mutexes/locks/etc that they are associated with. I was thinking about a struct with 2 ptrs but figured I'd ask around first. Or are people more or less comfortable passing them through func args?

wintry wasp
#

embedding them in structs is somewhat common, because you can then call Lock() and Unlock() on the struct value itself

#

you have to be careful to pass around the struct by pointer and not value if you do that

lyric wharf
#

ah yea thats pretty clean

#

thanks!

umbral kelp
#

go vet (ran as part of go test) will tell you if you accidentally copy a mutex