func (m *monitor) release(mode byte) { id := debug.GoroutineID() 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, debug.GoroutineID(), debug.StackTrace(3)} waitingList[waitInfo.goid] = waitInfo if m.holders == nil { m.holders = list.New() } m.diagnose(mode, []*lockUsage{waitInfo}) return waitInfo }