invariant_mutex.go
func NewInvariantMutex(check func()) (mu InvariantMutex) {
	if check == nil {
		panic("check must be non-nil.")
	}

	mu.check = check
	mu.checkIfEnabled()

	return
}
func NewInvariantMutex(check func()) (mu InvariantMutex) {
	if check == nil {
		panic("check must be non-nil.")
	}

	mu.check = check
	mu.checkIfEnabled()

	return
}
// Create a lock which, when EnableInvariantChecking has been called, will call
// the supplied function at moments when invariants protected by the lock
// should hold (e.g. just after acquiring the lock). The function should crash
// if an invariant is violated. It should not have side effects, as there are
// no guarantees that it will run.
//
// The invariants must hold at the time that NewInvariantMutex is called.