I am writing a custom Locker which does a check if Lock() is being called 
more than once and throws a panic if it does.
I tested it to see if I can use it with sync.Cond, and for the most part, 
it was running as intended, except once in a while
the panic check triggered.

Here's the dumbed down version of what I am trying to do:

https://play.golang.org/p/2tWqY221RM

I cannot get it to reproduce on the Go Playground, but copy paste it to 
your local computer and see if you get it to panic.
Here's what I got:

panic: Cannot lock twice
goroutine 5 [running]:
main.(*CustomLocker).Lock(0xc42000e2e0)
        /.../go/src/github.com/test/custom_locker.go:18 +0xc9
main.main.func1(0xc4200142c0, 0xc42000e2f0, 0xc42000e2d0)
        /.../go/src/github.com/test/custom_locker.go:42 +0x37
created by main.main
        /.../go/src/github.com/test/custom_locker.go:50 +0x159
exit status 2

I thought sync.Cond.Wait() should Unlock(), sleeps itself, then when awaken 
by Broadcast() try to Lock() again?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to