func()

in unison/mutex.go [62:87]


func (c Mutex) LockTimeout(duration time.Duration) bool {
	switch {
	case duration == 0:
		return c.TryLock()
	case duration < 0:
		if c.ch == nil {
			return false
		}
		c.Lock()
		return true
	}

	timer := time.NewTimer(duration)
	select {
	case <-c.ch:
		timer.Stop()
		return true
	case <-timer.C:
		select {
		case <-c.ch: // still lock, if timer and lock occured at the same time
			return true
		default:
			return false
		}
	}
}