示例#1
0
文件: deadlock.go 项目: pythoner/sync
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
		}
	}
}
示例#2
0
文件: deadlock.go 项目: zeuson/debug
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
}