github.com/piotrnar/gocoin@v0.0.0-20240512203912-faa0448c5e96/lib/others/sys/mutexes.go (about) 1 package sys 2 3 import ( 4 "fmt" 5 "runtime" 6 "sync" 7 ) 8 9 type Mutex struct { 10 sync.Mutex 11 locked bool 12 line int 13 file string 14 } 15 16 func (m *Mutex) Lock() { 17 m.Mutex.Lock() 18 m.locked = true 19 _, m.file, m.line, _ = runtime.Caller(1) 20 } 21 22 func (m *Mutex) Unlock() { 23 //_, m.file, m.line, _ = runtime.Caller(1) 24 m.locked = false 25 m.Mutex.Unlock() 26 } 27 28 func (m *Mutex) String() string { 29 if m.locked { 30 return fmt.Sprint("lock from ", m.file, ":", m.line) 31 } 32 return "unlocked" 33 //return fmt.Sprint("unlocked in ", m.file, ":", m.line) 34 }