func (m *monitor) release(mode byte) { id := goid.Get() for i := m.holders.Back(); i != nil; i = i.Prev() { if info := i.Value.(*lockUsage); info.goid == id && info.mode == mode { m.holders.Remove(i) break } } }
func (m *monitor) wait(mode byte) *lockUsage { globalMutex.Lock() defer globalMutex.Unlock() waitInfo := &lockUsage{m, mode, goid.Get(), debug.StackTrace(3, 0)} waitingList[waitInfo.goid] = waitInfo if m.holders == nil { m.holders = list.New() } m.diagnose(mode, []*lockUsage{waitInfo}) return waitInfo }